//
//  Settings.m
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import "Settings.h"
#import "Profile.h"
#import "Home.h"
#import "Stores.h"
#import "Inventory.h"
#import "Customers.h"
#import "Employees.h"
#import "Reports.h"
#import "Contacts.h"
#import "DataBaseManager.h"
#import "ServersyncClass.h"
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

@interface Settings ()
{
    //merchant view
    UILabel *merchantDataLabel,*merchantNameLabel,*addressLabel,*zipcodeLabel,*addressLabel2,*phNoLabel;
    UITextField *merchantnameTf,*addressTf,*zipcodeTf,*addressTf2,*phNoTf;
    UIButton *savemerchantDataBtn;
}

@end

@implementation Settings
{
    NSMutableArray *taxDataArray,*paymentDataArray;
    ServersyncClass *serverSyncClassObject;
    general_data *generalDataObject;
    NSURLConnection *CardConnection;
    NSMutableData *cardResponseData;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    generalDataObject =[general_data new];
    [generalDataObject  GetuserDataVariablesMethod];
    serverSyncClassObject=[ServersyncClass new];
    [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:serverSyncClassObject withObject:nil];
    [super viewDidLoad];
    
 
   
   // [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:[ServersyncClass sharedInstance] withObject:nil];
    
    y=0;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        y=y+20;
        
        
    }
    CGFloat width,height;
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    // //NSLog(@" %f,%f",width,height);
    
    
    
    backgroundcolorview=[[UIView alloc]init];
    backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
    [backgroundcolorview  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background" ofType:@"jpg"]]]];
    
    [self.view addSubview:backgroundcolorview];
    
    // [ContactsBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contactsactive" ofType:@"png"]] forState:UIControlStateNormal];
    
    sidemenu=[[UIView alloc]init];
    sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
    //sidemenu.hidden=YES;
    //[sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bluecolorstrip.jpg"]]];
    [sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluecolorstrip" ofType:@"jpg"]]]];
    
    
    NSString *pagetitle;
    pagetitle=@"Settings";
    
    
    
    navBar = [[UINavigationBar alloc] init];
    //navBar.translucent=NO;
    //navBar.barTintColor=[UIColor grayColor];
    navBar.frame=CGRectMake(0, 0,width , 50.0);
    
    [navBar setBackgroundImage:[UIImage imageNamed:@"logo-login-bg-short.png"] forBarMetrics:UIBarMetricsDefault];
    
    //[navBar setBackgroundColor:[UIColor blackColor]];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    titleLabel.font=[UIFont boldSystemFontOfSize:30.0];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text =pagetitle;
    [self.navigationItem setTitleView:titleLabel];
    
    
    //navItem.title = pagetitle;
    [navBar pushNavigationItem:self.navigationItem animated:false];
    
    [backgroundcolorview addSubview:navBar];
    
    
    menubutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menubutton setFrame:CGRectMake(0,0,50,50)];
    [menubutton addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    [menubutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow" ofType:@"png"]] forState:UIControlStateNormal];
    [navBar addSubview:menubutton];
    logoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [logoBtn setFrame:CGRectMake(60,0,250,50)];
    // [logoBtn addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logoBtn setImage:[UIImage imageNamed:@"headeraonelogo.png"] forState:UIControlStateNormal];
    [logoBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headeraonelogo" ofType:@"png"]] forState:UIControlStateNormal];
    
    [navBar addSubview:logoBtn];
    sationLbl=[[UILabel alloc] init];
    sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
    [sationLbl setFont:[UIFont systemFontOfSize:13.0f]];
    [sationLbl setBackgroundColor:[UIColor clearColor]];
    [sationLbl setTextColor:[UIColor blackColor]];
    [sationLbl setText:@"Station No:1"];
    sationLbl.lineBreakMode = NSLineBreakByWordWrapping;
    sationLbl.numberOfLines = 2;
    [sationLbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:sationLbl];
    
    EmpIdlbl=[[UILabel alloc] init];
    EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
    [EmpIdlbl setFont:[UIFont systemFontOfSize:13.0f]];
    [EmpIdlbl setBackgroundColor:[UIColor clearColor]];
    [EmpIdlbl setTextColor:[UIColor blackColor]];
    [EmpIdlbl setText:[NSString stringWithFormat:@"Employee Id: %@",[generalDataObject  userID]]];
    EmpIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    // EmpIdlbl.numberOfLines = 2;
    [EmpIdlbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:EmpIdlbl];
    
    
    Timelbl=[[UILabel alloc] init];
    Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
    [Timelbl setFont:[UIFont systemFontOfSize:13.0f]];
    [Timelbl setBackgroundColor:[UIColor clearColor]];
    [Timelbl setTextColor:[UIColor blackColor]];
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    //Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    
    // timer is set & will be triggered each second
    //[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showTime) userInfo:nil repeats:YES];
    Timelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Timelbl.numberOfLines = 2;
    [Timelbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:Timelbl];
    
    p=1;
    @autoreleasepool {
        for (int i=0; i< 10; i++)
        {
            
            categorybutton = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [categorybutton setFrame:CGRectMake(5,p,170,40)];
            [categorybutton addTarget:self action:@selector(categotybuttonclicked:) forControlEvents:UIControlEventTouchUpInside];
            categorybutton.tag=i;
            if (categorybutton.tag == 0)
            {
                [categorybutton setImage:[UIImage imageNamed:@"posnormal2.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 1)
            {
                [categorybutton setImage:[UIImage imageNamed:@"profilenormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 2)
            {
                [categorybutton setImage:[UIImage imageNamed:@"inventorynormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 3)
            {
                [categorybutton setImage:[UIImage imageNamed:@"customernormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 4)
            {
                [categorybutton setImage:[UIImage imageNamed:@"employeenormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 5)
            {
                [categorybutton setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 6)
            {
                [categorybutton setImage:[UIImage imageNamed:@"reportsnormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 7)
            {
                [categorybutton setImage:[UIImage imageNamed:@"contactsnormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 8)
            {
                [categorybutton setImage:[UIImage imageNamed:@"storesnormal.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 9)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"bluecolorstrip.jpg"] forState:UIControlStateNormal];
            }
            [sidemenu addSubview:categorybutton];
            p=p+categorybutton.frame.size.height;
        }
    }
    
    mainview=[[UIView alloc]init];
    mainview.frame=CGRectMake(10,60,width-20,height-200);
    [mainview setBackgroundColor:[UIColor grayColor]];
    [mainview  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"hqbackground69opacity.png"]]];
    [backgroundcolorview addSubview:mainview];
    CGFloat barbuttonwidth=(mainview.frame.size.width)/8;
    maintoolBar = [[UIToolbar alloc] init];
    maintoolBar.frame = CGRectMake(0, y, mainview.frame.size.width, 40);
    [maintoolBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    
    [maintoolBar setBackgroundImage:[UIImage imageNamed:@"toprightmenu.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    // maintoolBar.barTintColor=[UIColor redColor];
    scrollView = [[UIScrollView alloc] init];
    scrollView.frame = maintoolBar.frame;
    scrollView.bounds = maintoolBar.bounds;
    scrollView.autoresizingMask = maintoolBar.autoresizingMask;
    scrollView.showsVerticalScrollIndicator = false;
    scrollView.showsHorizontalScrollIndicator = false;
    scrollView.contentSize = CGSizeMake(maintoolBar.frame.size.width*2, maintoolBar.frame.size.height);
    NSMutableArray *items=[[NSMutableArray alloc]init];
    
    Applicationbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    Applicationbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20, 60);
    
    [Applicationbarbtn addTarget:self action:@selector(Applicationbarbutton) forControlEvents:UIControlEventTouchUpInside];
    // [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    Applicationbarbtn.tag=[items indexOfObject:Applicationbarbtn];
    [Applicationbarbtn setTitle:@"TS" forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [Applicationbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    Applicationbarbtn.showsTouchWhenHighlighted = YES;
    
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:Applicationbarbtn];
    [items  addObject:backBarButtonItem];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    Printerbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    Printerbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
    [Printerbarbtn setTitle:@"Printer" forState:UIControlStateNormal];
    [Printerbarbtn addTarget:self action:@selector(Printerbarbutton) forControlEvents:UIControlEventTouchUpInside];
    Printerbarbtn.tag=[items indexOfObject:Printerbarbtn];
    //[backButton2 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    Printerbarbtn.showsTouchWhenHighlighted = YES;
    
    
    UIBarButtonItem *backBarButtonItem2 = [[UIBarButtonItem alloc] initWithCustomView:Printerbarbtn];
    
    [items  addObject:backBarButtonItem2];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    taxbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    taxbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);
    [taxbarbtn setTitle:@"Tax" forState:UIControlStateNormal];
    
    [taxbarbtn addTarget:self action:@selector(taxbarbutton) forControlEvents:UIControlEventTouchUpInside];
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    taxbarbtn.showsTouchWhenHighlighted = YES;
    taxbarbtn.tag=[items indexOfObject:taxbarbtn];
    
    
    UIBarButtonItem *backBarButtonItem3 = [[UIBarButtonItem alloc] initWithCustomView:taxbarbtn];
    
    [items  addObject:backBarButtonItem3];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    paymentbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    paymentbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
    
    [paymentbarbtn addTarget:self action:@selector(paymentbarbutton) forControlEvents:UIControlEventTouchUpInside];
    // [backButton setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    paymentbarbtn.tag=[items indexOfObject:paymentbarbtn];
    [paymentbarbtn setTitle:@"Payment" forState:UIControlStateNormal];
    paymentbarbtn.showsTouchWhenHighlighted = YES;
    
    UIBarButtonItem *backBarButtonItem4 = [[UIBarButtonItem alloc] initWithCustomView:paymentbarbtn];
    [items  addObject:backBarButtonItem4];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    DBbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    DBbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
    [DBbarbtn setTitle:@"DataBase" forState:UIControlStateNormal];
    [DBbarbtn addTarget:self action:@selector(DBbarbutton) forControlEvents:UIControlEventTouchUpInside];
    DBbarbtn.tag=[items indexOfObject:DBbarbtn];
    //[backButton2 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    DBbarbtn.showsTouchWhenHighlighted = YES;
    
    
    UIBarButtonItem *backBarButtonItem5 = [[UIBarButtonItem alloc] initWithCustomView:DBbarbtn];
    
    [items  addObject:backBarButtonItem5];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    dataresetbarbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    dataresetbarbtn.frame = CGRectMake(0, 0, barbuttonwidth,60);
    [dataresetbarbtn setTitle:@"ServerUrl" forState:UIControlStateNormal];
    // dataresetbarbtn.backgroundColor=[UIColor greenColor];
    [dataresetbarbtn addTarget:self action:@selector(Dataresetbarbutton) forControlEvents:UIControlEventTouchUpInside];
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    dataresetbarbtn.showsTouchWhenHighlighted = YES;
    dataresetbarbtn.tag=[items indexOfObject:dataresetbarbtn];
    
    
    UIBarButtonItem *backBarButtonItem6 = [[UIBarButtonItem alloc] initWithCustomView:dataresetbarbtn];
    
    [items  addObject:backBarButtonItem6];
    CompanyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CompanyBtn.frame = CGRectMake(0, 0, barbuttonwidth-10,60);
    [CompanyBtn setTitle:@"Company" forState:UIControlStateNormal];
    // dataresetbarbtn.backgroundColor=[UIColor greenColor];
    [CompanyBtn addTarget:self action:@selector(CompanyImageBarbutton) forControlEvents:UIControlEventTouchUpInside];
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    CompanyBtn.showsTouchWhenHighlighted = YES;
    CompanyBtn.tag=[items indexOfObject:CompanyBtn];
    
    
    UIBarButtonItem *backBarButtonItem7 = [[UIBarButtonItem alloc] initWithCustomView:CompanyBtn];
    
    [items  addObject:backBarButtonItem7];
    
    CardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CardBtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);
    [CardBtn setTitle:@"Card" forState:UIControlStateNormal];
    // dataresetbarbtn.backgroundColor=[UIColor greenColor];
    [CardBtn addTarget:self action:@selector(CardBarbutton) forControlEvents:UIControlEventTouchUpInside];
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    CardBtn.showsTouchWhenHighlighted = YES;
    CardBtn.tag=[items indexOfObject:CardBtn];
    
    
    UIBarButtonItem *backBarButtonItem8 = [[UIBarButtonItem alloc] initWithCustomView:CardBtn];
    
    [items  addObject:backBarButtonItem8];
    
    [maintoolBar setItems:items animated:NO];
    [maintoolBar sizeToFit];
    //[maintoolBar addSubview:scrollView];
    [mainview addSubview:maintoolBar];
    
    
    logoimageview=[[UIImageView alloc]init];
    logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
    [logoimageview setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aoneposlogo" ofType:@"png"]]];
    [self.view addSubview:logoimageview];
    
    helpiconButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [helpiconButton setFrame:CGRectMake(width-180,y+40,70,70)];
    [helpiconButton addTarget:self action:@selector(helpiconclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[helpiconButton setImage:[UIImage imageNamed:@"helpicon.png"] forState:UIControlStateNormal];
    [helpiconButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"helpicon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [self.view addSubview:helpiconButton];
    logouticonButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [logouticonButton setFrame:CGRectMake(width-100,y+40,70,70)];
    [logouticonButton addTarget:self action:@selector(logoutButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logouticonButton setImage:[UIImage imageNamed:@"logoutbutton.png"] forState:UIControlStateNormal];
    [logouticonButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logoutbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [self.view addSubview:logouticonButton];
    y=0;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        y=y+20;
    }
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    
    [self updateUI];
    
    
//add sub views
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[printerview removeFromSuperview];
    [dataresetView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    
    
    ApplicationView=[[UIView alloc]init];
    ApplicationView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [ApplicationView setBackgroundColor:[UIColor whiteColor]];
    [mainview addSubview:ApplicationView];
    
    addApplicationDataView =[[UIView alloc]init];
    addApplicationDataView.frame=CGRectMake(10, 10, ApplicationView.frame.size.width-20, ApplicationView.frame.size.height-20);
    [addApplicationDataView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    addApplicationDataView.layer.cornerRadius=8;
    [ApplicationView addSubview:addApplicationDataView];
    
    CGFloat Btnwdth=(addApplicationDataView.frame.size.width)/3;
    
    DeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DeptBtn.frame=CGRectMake(40,40,Btnwdth+40,40);
    //[DeptBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [DeptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [DeptBtn setTitle:@"Departments" forState:UIControlStateNormal];
    [DeptBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [addApplicationDataView addSubview:DeptBtn];
    
    DepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(40,79,Btnwdth+40,200) style:UITableViewStylePlain];
    DepartmentsTable.delegate = self;
    DepartmentsTable.dataSource = self;
    DepartmentsTable.scrollEnabled = YES;
    DepartmentsTable.layer.cornerRadius=8;
    [addApplicationDataView addSubview:DepartmentsTable];
    
    ItemsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+100,40,Btnwdth+40,40);
    //[DeptBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [ItemsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [ItemsBtn setTitle:@"Items" forState:UIControlStateNormal];
    [ItemsBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [addApplicationDataView addSubview:ItemsBtn];
    
    ItemsTable = [[UITableView alloc] initWithFrame:CGRectMake(40+DeptBtn.frame.size.width+100,79,Btnwdth+40,200) style:UITableViewStylePlain];
    ItemsTable.delegate = self;
    ItemsTable.dataSource = self;
    ItemsTable.scrollEnabled = YES;
    ItemsTable.layer.cornerRadius=8;
    ItemsTable.hidden=YES;
    [addApplicationDataView addSubview:ItemsTable];
    
    @autoreleasepool {
        saveDeptsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        saveDeptsBtn.frame=CGRectMake(130,79+250,80,30);
        //[saveDeptsBtn addTarget:self action:@selector(SaveDepartments) forControlEvents:UIControlEventTouchUpInside];
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveDeptsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saveDeptsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [addApplicationDataView addSubview:saveDeptsBtn];
        
        SaveItemsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        SaveItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+190,79+250,80,30);
        //[SaveItemsBtn addTarget:self action:@selector(Saveitems) forControlEvents:UIControlEventTouchUpInside];
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveItemsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveItemsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [addApplicationDataView addSubview:SaveItemsBtn];
    }
   
     helpiconButton.hidden=YES;
   
}
-(void)viewWillAppear:(BOOL)animated
{
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    if (!deptSArray){
        deptSArray=[[NSMutableArray alloc]init];
        ChecksArray=[[NSMutableArray alloc]init];
        DepartmentsArray=[[NSMutableArray alloc]init];
    }
   
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id,check_value FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];

 
    
    if ([deptsArray count]>0)
    {
        for (NSDictionary *myDict in deptsArray)
        {
            [DepartmentsArray addObject:[myDict objectForKey:@"department_id"]];
            [ChecksArray addObject:[myDict objectForKey:@"check_value"]];
        }
    }
    
    if ([DepartmentsArray count]>0)
    {
        if (!ItemsArray){
        ItemsArray=[[NSMutableArray alloc]init];
        ItemChecksArray=[[NSMutableArray alloc]init];
        }
        NSString *str=[DepartmentsArray objectAtIndex:0];
        NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_department,inventary_item_name,check_value FROM inventorytable"];
        NSMutableArray *productdataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productdataArray];
        
        for (NSDictionary *myDict in productdataArray)
        {
            NSString *valuesstr=[myDict objectForKey:@"inventary_department"];
            if ([valuesstr isEqualToString:str])
            {
                NSString *valuesstr=[myDict objectForKey:@"inventary_item_name"];
                
                [ItemChecksArray addObject:[myDict objectForKey:@"check_value"]];
                [ItemsArray addObject:valuesstr];
                
            }
        }
        
        [ItemsTable setHidden:NO];
        
    }
    [super viewWillAppear:YES];
   
}
-(void)showTime
{
    
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    // Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    //Timelbl.text=[[NSDate date] description];
    
    
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight||toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {
        isLandScope=YES;
        
    }else
    {
        isLandScope=NO;
    }
    [self updateUI];
}


-(void)Applicationbarbutton
{
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [Applicationbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    if (!ApplicationView)
    ApplicationView=[[UIView alloc]init];
    ApplicationView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [ApplicationView setBackgroundColor:[UIColor whiteColor]];
    [mainview addSubview:ApplicationView];
    
    if (!addApplicationDataView)
    addApplicationDataView =[[UIView alloc]init];
    addApplicationDataView.frame=CGRectMake(10, 10, ApplicationView.frame.size.width-20, ApplicationView.frame.size.height-20);
    [addApplicationDataView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    addApplicationDataView.layer.cornerRadius=8;
    [ApplicationView addSubview:addApplicationDataView];
    
    CGFloat Btnwdth=(addApplicationDataView.frame.size.width)/3;
     if (!DeptBtn)
    DeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DeptBtn.frame=CGRectMake(40,40,Btnwdth+40,40);
    //[DeptBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    [DeptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [DeptBtn setTitle:@"Departments" forState:UIControlStateNormal];
    [DeptBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [addApplicationDataView addSubview:DeptBtn];
    if (!DepartmentsTable)
    DepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(40,79,Btnwdth+40,200) style:UITableViewStylePlain];
    DepartmentsTable.delegate = self;
    DepartmentsTable.dataSource = self;
    DepartmentsTable.scrollEnabled = YES;
    DepartmentsTable.layer.cornerRadius=8;
    [addApplicationDataView addSubview:DepartmentsTable];
     if (!ItemsBtn)
    ItemsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    ItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+100,40,Btnwdth+40,40);
    //[DeptBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [ItemsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [ItemsBtn setTitle:@"Items" forState:UIControlStateNormal];
    [ItemsBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [addApplicationDataView addSubview:ItemsBtn];
    if (!ItemsTable)
    ItemsTable = [[UITableView alloc] initWithFrame:CGRectMake(40+DeptBtn.frame.size.width+100,79,Btnwdth+40,200) style:UITableViewStylePlain];
    ItemsTable.delegate = self;
    ItemsTable.dataSource = self;
    ItemsTable.scrollEnabled = YES;
    ItemsTable.layer.cornerRadius=8;
    [addApplicationDataView addSubview:ItemsTable];
    
    @autoreleasepool {
        saveDeptsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        saveDeptsBtn.frame=CGRectMake(130,79+250,80,30);
       // [saveDeptsBtn addTarget:self action:@selector(SaveDepartments) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveDeptsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saveDeptsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [addApplicationDataView addSubview:saveDeptsBtn];
        
        SaveItemsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+190,79+250,80,30);
       // [SaveItemsBtn addTarget:self action:@selector(Saveitems) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveItemsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveItemsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [addApplicationDataView addSubview:SaveItemsBtn];
    }
    
    
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];

    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
     //[CompanyView removeFromSuperview];
    
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    
    [mainview addSubview:ApplicationView];

    
}
-(void)CardBarbutton
{
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [CardBtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    
    //Card View
  NSString *querySQL = [NSString stringWithFormat: @"SELECT paymentprocessorname FROM paymentprocessorpreferencess"];
    NSMutableArray *cardArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:cardArray];
    
    
    NSMutableDictionary *cardDict=[[NSMutableDictionary alloc]init];
    if ([cardArray count]>0)
    {
        cardDict=[cardArray objectAtIndex:0];
    }
    
    NSString *CardpaymentType=[cardDict objectForKey:@"paymentprocessorname"];
    if (!CardBackView)
    CardBackView=[[UIView alloc]init];
    CardBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [CardBackView setBackgroundColor:[UIColor whiteColor]];
    [mainview addSubview:CardBackView];
    if (!CardView)
    CardView =[[UIScrollView alloc]init];
    CardView.frame=CGRectMake(10, 10, CardBackView.frame.size.width-20, CardBackView.frame.size.height-20);
    CardView.contentSize=CGSizeMake( CardBackView.frame.size.width-20, CardBackView.frame.size.height+100);
    [CardView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    CardView.layer.cornerRadius=8;
    [CardBackView addSubview:CardView];
    
    CGFloat CardW=CardView.frame.size.width/2;
    CGFloat cardX=CardW/2;
    if (!paymentLabel)
    paymentLabel = [[UILabel alloc]init];
    paymentLabel.frame=CGRectMake(cardX-100,30 ,300,40);
    [paymentLabel setText:@"Select the Payment Type Process"];
    [paymentLabel setFont:[UIFont systemFontOfSize:20.0f]];
    [paymentLabel setBackgroundColor:[UIColor clearColor]];
    [paymentLabel setTextColor:[UIColor whiteColor]];
    [CardView addSubview:paymentLabel];
     if (!paymentButton)
    paymentButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    paymentButton.frame=CGRectMake(cardX-100, 80, 250, 40);
    [paymentButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    paymentButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    if ([CardpaymentType length]>0)
    {
         [paymentButton setTitle:CardpaymentType forState:UIControlStateNormal];
    }else{
    [paymentButton setTitle:@"First Data" forState:UIControlStateNormal];
    }
    [paymentButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [paymentButton addTarget:self action:@selector(paymentButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [CardView addSubview:paymentButton];
    if (!paymentArray)
    paymentArray = [[NSArray alloc]initWithObjects:@"Express Manual",@"Mercury",nil];
    if (!paymentTableView)
    paymentTableView = [[UITableView alloc] initWithFrame:CGRectMake(cardX-100, 120, 250, 80) style:UITableViewStylePlain];
    paymentTableView.backgroundColor=[UIColor whiteColor];
    paymentTableView.delegate = self;
    paymentTableView.dataSource = self;
    paymentTableView.scrollEnabled = YES;
    paymentTableView.hidden=YES;
    [paymentTableView.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [paymentTableView.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [CardView addSubview:paymentTableView];
   
    //CGFloat CardW=CardView.frame.size.width/2;
    //CGFloat cardX=CardW/2;
     if (!primaryurllbl)
    primaryurllbl=[[UILabel alloc]init];
    primaryurllbl.frame=CGRectMake(cardX-100,150 ,180,40);
    [primaryurllbl setText:@"Primary Url"];
    [primaryurllbl setFont:[UIFont systemFontOfSize:20.0f]];
    [primaryurllbl setBackgroundColor:[UIColor clearColor]];
    [primaryurllbl setTextColor:[UIColor whiteColor]];
    [CardView addSubview:primaryurllbl];
    if (!PrimaryField)
    PrimaryField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    PrimaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 150, CardW,40);
    PrimaryField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    PrimaryField.leftView = paddingview;
    PrimaryField.leftViewMode = UITextFieldViewModeAlways;
    PrimaryField.textAlignment= NSTextAlignmentLeft;
    PrimaryField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    //[PrimaryField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    PrimaryField.backgroundColor=[UIColor whiteColor];
    [PrimaryField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [PrimaryField.layer setBorderWidth:2.0];
    [PrimaryField.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [CardView addSubview:PrimaryField];
     if (!Securllbl)
    Securllbl=[[UILabel alloc]init];
    Securllbl.frame=CGRectMake(cardX-100,210 ,180,40);
    [Securllbl setText:@"Secondary Url "];
    [Securllbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Securllbl setBackgroundColor:[UIColor clearColor]];
    [Securllbl setTextColor:[UIColor whiteColor]];
    [CardView addSubview:Securllbl];
    if (!SecondaryField)
    SecondaryField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    SecondaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 210, CardW,40);
    
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    SecondaryField.leftView = paddingview2;
    //SecondaryField.placeholder = @"Enter Server Url";
    SecondaryField.textAlignment= NSTextAlignmentLeft;
    SecondaryField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    SecondaryField.backgroundColor=[UIColor whiteColor];
    SecondaryField.leftViewMode = UITextFieldViewModeAlways;
    SecondaryField.delegate=self;
    [SecondaryField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [SecondaryField.layer setBorderWidth:2.0];
    [SecondaryField.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [CardView addSubview:SecondaryField];
    if (!merchantNolbl)
    merchantNolbl=[[UILabel alloc]init];
    merchantNolbl.frame=CGRectMake(cardX-100,270 ,180,40);
    [merchantNolbl setText:@"Merchant Number"];
    [merchantNolbl setFont:[UIFont systemFontOfSize:20.0f]];
    [merchantNolbl setBackgroundColor:[UIColor clearColor]];
    [merchantNolbl setTextColor:[UIColor whiteColor]];
    [CardView addSubview:merchantNolbl];
    if (!MerchantField)
    MerchantField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    MerchantField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 270, CardW,40);
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    MerchantField.leftView = paddingview3;
    MerchantField.placeholder = @"Enter MID";
    MerchantField.textAlignment= NSTextAlignmentLeft;
    MerchantField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    MerchantField.backgroundColor=[UIColor whiteColor];
    MerchantField.leftViewMode = UITextFieldViewModeAlways;
    MerchantField.delegate=self;
    [MerchantField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [MerchantField.layer setBorderWidth:2.0];
    [MerchantField.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [CardView addSubview:MerchantField];
    if (!terminalNolbl)
    terminalNolbl=[[UILabel alloc]init];
    terminalNolbl.frame=CGRectMake(cardX-100,330 ,180,40);
    [terminalNolbl setText:@"Terminal Number "];
    [terminalNolbl setFont:[UIFont systemFontOfSize:20.0f]];
    [terminalNolbl setBackgroundColor:[UIColor clearColor]];
    [terminalNolbl setTextColor:[UIColor whiteColor]];
    [CardView addSubview:terminalNolbl];
     if (!TerminalField)
    TerminalField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    TerminalField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 330, CardW,40);
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    TerminalField.leftView = paddingview4;
    TerminalField.placeholder = @"Enter TID";
    TerminalField.textAlignment= NSTextAlignmentLeft;
    TerminalField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    TerminalField.backgroundColor=[UIColor whiteColor];
    TerminalField.leftViewMode = UITextFieldViewModeAlways;
    TerminalField.delegate=self;
    [TerminalField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [TerminalField.layer setBorderWidth:2.0];
    [TerminalField.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [CardView addSubview:TerminalField];
    if (!timeoutlbl)
    //timeoutlbl=[[UILabel alloc]init];
    timeoutlbl.frame=CGRectMake(cardX-100,390 ,180,40);
    [timeoutlbl setText:@"Time out"];
    [timeoutlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [timeoutlbl setBackgroundColor:[UIColor clearColor]];
    [timeoutlbl setTextColor:[UIColor whiteColor]];
    timeoutlbl.hidden=YES;
    [CardView addSubview:timeoutlbl];
    if (!timeoutTextField)
    //timeoutTextField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    timeoutTextField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 390, CardW,40);
    UIView *paddingview5=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    timeoutTextField.leftView = paddingview5;
    timeoutTextField.placeholder = @"Enter time";
    timeoutTextField.textAlignment= NSTextAlignmentLeft;
    TerminalField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    timeoutTextField.backgroundColor=[UIColor whiteColor];
    timeoutTextField.leftViewMode = UITextFieldViewModeAlways;
    timeoutTextField.delegate=self;
     timeoutTextField.hidden=YES;
    [timeoutTextField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [timeoutTextField.layer setBorderWidth:2.0];
    [timeoutTextField.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [CardView addSubview:timeoutTextField];
    if (!ProcessBtn)
    ProcessBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    ProcessBtn.frame=CGRectMake(cardX-80,395 ,30,30);
    [ProcessBtn addTarget:self action:@selector(ProcessClicked) forControlEvents:UIControlEventTouchUpInside];
    [ProcessBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [ProcessBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [ProcessBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [CardView addSubview:ProcessBtn];
    if (!Processdebittextlbl)
    Processdebittextlbl=[[UILabel alloc] init];
    Processdebittextlbl.frame=CGRectMake(cardX-30,390,CardW+CardW/2, 40);
    [Processdebittextlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Processdebittextlbl setBackgroundColor:[UIColor clearColor]];
    [Processdebittextlbl setTextColor:[UIColor whiteColor]];
    [Processdebittextlbl setText:@"Process Debit Cards Through This Credit Card Processor"];
    [Processdebittextlbl setTextAlignment:NSTextAlignmentLeft];
    [CardView addSubview:Processdebittextlbl];
    
     if (!RequireBtn)
    RequireBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    RequireBtn.frame=CGRectMake(cardX-80,445 ,30,30);
    [RequireBtn addTarget:self action:@selector(RequireBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [RequireBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [RequireBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [RequireBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [CardView addSubview:RequireBtn];
     if (!requiretextlbl)
    requiretextlbl=[[UILabel alloc] init];
    requiretextlbl.frame=CGRectMake(cardX-30,440,CardW+CardW/2, 40);
    [requiretextlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [requiretextlbl setBackgroundColor:[UIColor clearColor]];
    [requiretextlbl setTextColor:[UIColor whiteColor]];
    [requiretextlbl setText:@"Require CVV2 for non-swiped CCs"];
    [requiretextlbl setTextAlignment:NSTextAlignmentLeft];
    [CardView addSubview:requiretextlbl];
    
    if (!saveCardDataBtn)
    saveCardDataBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    saveCardDataBtn.frame= CGRectMake(CardW-40,520, 100, 40);
    [saveCardDataBtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    saveCardDataBtn.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [saveCardDataBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [saveCardDataBtn addTarget:self action:@selector(saveCardDataClick) forControlEvents:UIControlEventTouchUpInside];
    //[addprinterdataView addSubview:printerNameButton];
    [saveCardDataBtn setTitle:@"Save" forState:UIControlStateNormal];
    [CardView addSubview:saveCardDataBtn];
    
    NSString *paymenttype=paymentButton.titleLabel.text;
    
    if ([paymenttype isEqualToString:@"Express Manual"]){
        //[PrimaryField setHidden:YES];
        
        primaryurllbl.hidden=YES;
        PrimaryField.hidden=YES;
        SecondaryField.hidden=YES;
        Securllbl.hidden=YES;
        MerchantField.hidden=YES;
        merchantNolbl.hidden=YES;
        terminalNolbl.hidden=YES;
        TerminalField.hidden=YES;
        ProcessBtn.hidden=YES;
        Processdebittextlbl.hidden=YES;
        RequireBtn.hidden=YES;
        requiretextlbl.hidden=YES;
        saveCardDataBtn.hidden=YES;
        timeoutlbl.hidden=YES;
        timeoutTextField.hidden=YES;
    }else if([paymenttype isEqualToString:@"First Data"]){
        primaryurllbl.hidden=NO;
        PrimaryField.hidden=NO;
        SecondaryField.hidden=NO;
        Securllbl.hidden=NO;
        MerchantField.hidden=NO;
        merchantNolbl.hidden=NO;
        terminalNolbl.hidden=NO;
        TerminalField.hidden=NO;
        ProcessBtn.hidden=NO;
        Processdebittextlbl.hidden=NO;
        RequireBtn.hidden=NO;
        requiretextlbl.hidden=NO;
        saveCardDataBtn.hidden=NO;
        timeoutlbl.hidden=YES;
        timeoutTextField.hidden=YES;
        terminalNolbl.text=@"Terminal Number";
        TerminalField.placeholder=@"Enter TID";
        
        TerminalField.text=@"";
        PrimaryField.text=@"";
        SecondaryField.text=@"";
        MerchantField.text=@"";
    }else if([paymenttype isEqualToString:@"Mercury"]){
        
        NSString *merquerySQL = [NSString stringWithFormat: @"SELECT mercury_primary_url,mercury_secondary_url,mercury_merchant_id,mercury_password FROM mercury_pay_table"];
        NSMutableArray *mercuryArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:merquerySQL resultsArray:mercuryArray];
        NSString *primaryurl,*secondaryurl,*merchantId,*password;
        if ([mercuryArray count]>0)
        {
            NSDictionary *Dict=[mercuryArray objectAtIndex:0];
            primaryurl=[Dict objectForKey:@"mercury_primary_url"];
            secondaryurl=[Dict objectForKey:@"mercury_secondary_url"];
            merchantId=[Dict objectForKey:@"mercury_merchant_id"];
            password=[Dict objectForKey:@"mercury_password"];
           
        }
        primaryurllbl.hidden=NO;
        PrimaryField.hidden=NO;
        SecondaryField.hidden=NO;
        Securllbl.hidden=NO;
        MerchantField.hidden=NO;
        merchantNolbl.hidden=NO;
        terminalNolbl.hidden=NO;
        TerminalField.hidden=NO;
        ProcessBtn.hidden=YES;
        Processdebittextlbl.hidden=YES;
        RequireBtn.hidden=YES;
        requiretextlbl.hidden=YES;
        timeoutlbl.hidden=NO;
        timeoutTextField.hidden=NO;
        saveCardDataBtn.hidden=NO;
        terminalNolbl.text=@"Password";
        TerminalField.placeholder=@"Enter password";
        TerminalField.text=password;
        PrimaryField.text=primaryurl;
        SecondaryField.text=secondaryurl;
        MerchantField.text=merchantId;
    }
    paymenttype=nil;
}
-(void)saveCardDataClick
{
    if ([paymentButton.titleLabel.text  isEqualToString:@"Mercury"])
    {
        NSString *querySQL = [NSString stringWithFormat: @"SELECT mercury_primary_url,mercury_merchant_id FROM mercury_pay_table"];
        NSMutableArray *merchantArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:merchantArray];
        
        if ([merchantArray count]>0){
            NSDictionary *dict=[merchantArray objectAtIndex:0];
            NSString *merchentId=[dict objectForKey:@"mercury_merchant_id"];
            
            NSString *updateSQL =@"UPDATE mercury_pay_table SET mercury_primary_url=?, mercury_secondary_url=?,mercury_merchant_id=?,mercury_password=? WHERE mercury_merchant_id=?";
            
            NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:PrimaryField.text,SecondaryField.text,MerchantField.text,TerminalField.text,merchentId, nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:updateArray];
            
            NSString *selectquerySQL = [NSString stringWithFormat: @"SELECT unique_id,created_timestamp,modified_timestamp,mercury_primary_url,mercury_secondary_url,mercury_merchant_id,mercury_password,server_local FROM mercury_pay_table"];
            NSMutableArray *merchantdataArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:selectquerySQL resultsArray:merchantdataArray];
            
          
            NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
            [CategoryDict setObject:merchantdataArray forKey:@"fields"];
            NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
            
            
            NSError *err;
            
            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
            
            NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
            
            if(![generalDataObject  connectedToInternet])
            {
               
                NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
                NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"mercury_pay_table",[generalDataObject getsystemDatetime], nil];
                
                [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
                
            }else if([generalDataObject  connectedToInternet]){
                
                if ([[generalDataObject  OriginalbaseURLstr] length]>0)
                {
                    
                    // //NSLog(@"%@",str);
                    NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=mercury_pay_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                    
                    // //NSLog(@"%@",str);
                    
                    NSURL *url=[NSURL URLWithString:string];
                    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                    // //NSLog(@"%@",url);
                    
                    [request setHTTPMethod:@"POST"];
                    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                    //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                    
                    CardConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                    
                    [CardConnection start];
                }
            }
            
        }else{
            
          NSString *insertSQL =@"insert into mercury_pay_table (unique_id,created_timestamp,modified_timestamp,mercury_primary_url,mercury_secondary_url,mercury_merchant_id,mercury_password) values(?,?,?,?,?,?,?)";
            NSMutableArray *merchantArray=[[NSMutableArray alloc]initWithObjects:[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],PrimaryField.text,SecondaryField.text,MerchantField.text,TerminalField.text, nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:merchantArray];
            
            NSString *selectquerySQL = [NSString stringWithFormat: @"SELECT unique_id,created_timestamp,modified_timestamp,mercury_primary_url,mercury_secondary_url,mercury_merchant_id,mercury_password,server_local FROM mercury_pay_table"];
            NSMutableArray *merchantdataArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:selectquerySQL resultsArray:merchantdataArray];
            
            
            NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
            [CategoryDict setObject:merchantdataArray forKey:@"fields"];
            NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];

            NSError *err;
            
            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
            
            NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
            
            if(![generalDataObject  connectedToInternet]){
                
            
                NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
                NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"mercury_pay_table",[generalDataObject getsystemDatetime], nil];
                
                [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];

                
            }
            else if([generalDataObject  connectedToInternet]){
                
                if ([[generalDataObject  OriginalbaseURLstr] length]>0)
                {
                    
                    // //NSLog(@"%@",str);
                    NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=mercury_pay_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                    
                    // //NSLog(@"%@",str);
                    
                    NSURL *url=[NSURL URLWithString:string];
                    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                    // //NSLog(@"%@",url);
                    
                    [request setHTTPMethod:@"POST"];
                    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                    //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                    
                    CardConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                    
                    [CardConnection start];
                    
                }
            }
        }
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Mercury Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }
   //PrimaryField.text=@"",SecondaryField.text=@"",MerchantField.text=@"",TerminalField.text=@"";
    
    
}
-(void)paymentButtonClick
{
    if (paymentTableView.hidden==1){
        [paymentTableView setHidden:NO];
        
       primaryurllbl.hidden=YES;
          PrimaryField.hidden=YES;
  
    }else if (paymentTableView.hidden==0){
        [paymentTableView setHidden:YES];
        
        primaryurllbl.hidden=NO;
        PrimaryField.hidden=NO;
        //alignLineSpaButton.hidden=NO;
    }
    
}
-(void)ProcessClicked
{
    if (ProcessBtn.selected){
        [ProcessBtn setSelected:NO];
        
    }else if(!ProcessBtn.selected){
        [ProcessBtn setSelected:YES];
        
    }
   
}
-(void)RequireBtnClicked
{
    if (RequireBtn.selected){
        [RequireBtn setSelected:NO];
        
    }else if(!RequireBtn.selected){
        [RequireBtn setSelected:YES];
        
    }
}
-(void)CompanyImageBarbutton
{
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [CompanyBtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
   
    
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    
//Company View
    if (!CompanyBackView)
    CompanyBackView=[[UIView alloc]init];
    CompanyBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [CompanyBackView setBackgroundColor:[UIColor whiteColor]];
    [mainview addSubview:CompanyBackView];
    
    CompanyView =[[UIScrollView alloc]init];
    CompanyView.frame=CGRectMake(10, 10, CompanyBackView.frame.size.width-20, CompanyBackView.frame.size.height-20);
    CompanyView.contentSize=CGSizeMake(CompanyBackView.frame.size.width-20, CompanyBackView.frame.size.height+100);
    [CompanyView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    CompanyView.layer.cornerRadius=8;
    [CompanyBackView addSubview:CompanyView];
    
    
     CGFloat Homewdth=(CompanyView.frame.size.width)/2;
     if (!CompanyTextF)
    CompanyTextF = [[UITextField alloc]initWithFrame:CGRectMake(Homewdth-220, 40, Homewdth-100, 40)];
    
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    CompanyTextF.leftView = paddingview;
    CompanyTextF.placeholder = @"Enter CompanyName";
   // CompanyTextF.text=[generalDataObject  OriginalbaseURLstr];
    CompanyTextF.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CompanyTextF.textAlignment= NSTextAlignmentLeft;
    CompanyTextF.backgroundColor=[UIColor whiteColor];
    [CompanyTextF.layer setBorderWidth:2.0];
    CompanyTextF.leftViewMode = UITextFieldViewModeAlways;
    CompanyTextF.delegate=self;
    [CompanyTextF setAutocorrectionType:UITextAutocorrectionTypeNo];
    [CompanyTextF.layer setBorderColor:[[UIColor blackColor] CGColor]];
    CompanyTextF.autocapitalizationType = UITextAutocapitalizationTypeNone;
    //[CompanyView addSubview:CompanyTextF];
     if (!SubmitCmpyBtn)
    SubmitCmpyBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    SubmitCmpyBtn.frame=CGRectMake(CompanyTextF.frame.size.width+Homewdth-200,40, 100, 40);
    [SubmitCmpyBtn addTarget:self action:@selector(SaveCompanyname) forControlEvents:UIControlEventTouchUpInside];
    
    [SubmitCmpyBtn setTitle:@"Submit" forState:UIControlStateNormal];
    [SubmitCmpyBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [SubmitCmpyBtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    //[CompanyView addSubview:SubmitCmpyBtn];
     if (!HomeImageView)
    HomeImageView=[[UIImageView alloc]init];
    HomeImageView.frame=CGRectMake(20,20,Homewdth-80,Homewdth-80);
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
    UIImage *img2 = [UIImage imageWithContentsOfFile:getImagePath];
    HomeImageView.backgroundColor = [UIColor colorWithPatternImage:img2];
    [CompanyView addSubview:HomeImageView];
    if (!HomeImageBtn)
    HomeImageBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    HomeImageBtn.frame=CGRectMake(40,Homewdth-40,Homewdth-80,40);
    [HomeImageBtn addTarget:self action:@selector(SelectTheHomeimage) forControlEvents:UIControlEventTouchUpInside];
    [HomeImageBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [HomeImageBtn setTitle:@"Set Home Image" forState:UIControlStateNormal];
    [HomeImageBtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    [CompanyView addSubview:HomeImageBtn];
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT merchant_name,merchant_address,merchant_zipcode,server_local,merchant_address2,merchant_phone FROM merchant_info_table"];
    NSMutableArray *mertchantArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:mertchantArray];
    NSString *merchnatname,*address1,*address2,*phno,*zipcode;
    if ([mertchantArray count]>0)
    {
        NSDictionary *Dict=[mertchantArray objectAtIndex:0];
        merchnatname=[Dict objectForKey:@"merchant_name"];
        address1=[Dict objectForKey:@"merchant_address"];
        address2=[Dict objectForKey:@"merchant_address2"];
        phno=[Dict objectForKey:@"merchant_phone"];
        zipcode=[Dict objectForKey:@"merchant_zipcode"];
        
    }
    //merchant view
    CGFloat merchantW=CompanyView.frame.size.width/2;
    if (!merchantDataLabel)
    merchantDataLabel = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+60, 20, merchantW, 30)];
    merchantDataLabel.text= @"Merchant Details";
    merchantDataLabel.backgroundColor=[UIColor clearColor];
    merchantDataLabel.textColor=[UIColor whiteColor];
    merchantDataLabel.font = [UIFont systemFontOfSize:25.0f];
    [CompanyView addSubview:merchantDataLabel];
     if (!merchantNameLabel)
    merchantNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+10, 80, 100, 30)];
    merchantNameLabel.text= @"Name";
    merchantNameLabel.backgroundColor=[UIColor clearColor];
    merchantNameLabel.textColor=[UIColor whiteColor];
    merchantNameLabel.font = [UIFont systemFontOfSize:22.0f];
    [CompanyView addSubview:merchantNameLabel];
    if (!merchantnameTf)
    merchantnameTf = [[UITextField alloc]initWithFrame:CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 80,  merchantW/2, 30)];
    merchantnameTf.text=merchnatname;
    merchantnameTf.borderStyle = UITextBorderStyleRoundedRect;
    [CompanyView addSubview:merchantnameTf];
    if (!addressLabel)
    addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+10, 140,100, 30)];
    addressLabel.text= @"Address";
    addressLabel.backgroundColor=[UIColor clearColor];
    addressLabel.textColor=[UIColor whiteColor];
    addressLabel.font = [UIFont systemFontOfSize:22.0f];
    [CompanyView addSubview:addressLabel];
    if (!addressTf)
    addressTf = [[UITextField alloc]initWithFrame:CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 140, merchantW/2, 30)];
    addressTf.text=address1;
    addressTf.borderStyle = UITextBorderStyleRoundedRect;
    [CompanyView addSubview:addressTf];
    if (!addressLabel2)
        addressLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+10, 200,100, 30)];
    addressLabel2.text= @"Address2";
    addressLabel2.backgroundColor=[UIColor clearColor];
    addressLabel2.textColor=[UIColor whiteColor];
    addressLabel2.font = [UIFont systemFontOfSize:22.0f];
    [CompanyView addSubview:addressLabel2];
    if (!addressTf2)
    addressTf2 = [[UITextField alloc]initWithFrame:CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 200, merchantW/2, 30)];
    addressTf2.text=address2;
    addressTf2.borderStyle = UITextBorderStyleRoundedRect;
    [CompanyView addSubview:addressTf2];
    if (!phNoLabel)
    phNoLabel = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+10, 260,100, 30)];
    phNoLabel.text= @"Phone No";
    phNoLabel.backgroundColor=[UIColor clearColor];
    phNoLabel.textColor=[UIColor whiteColor];
    phNoLabel.font = [UIFont systemFontOfSize:22.0f];
    [CompanyView addSubview:phNoLabel];
    
    if (!phNoTf)
    phNoTf = [[UITextField alloc]initWithFrame:CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 260, merchantW/2, 30)];
    phNoTf.text=phno;
    phNoTf.borderStyle = UITextBorderStyleRoundedRect;
    [CompanyView addSubview:phNoTf];
    
    if (!zipcodeLabel)
    zipcodeLabel = [[UILabel alloc]initWithFrame:CGRectMake(merchantW+10, 320, 100, 30)];
    zipcodeLabel.text= @"Zip";
    zipcodeLabel.backgroundColor=[UIColor clearColor];
    zipcodeLabel.textColor=[UIColor whiteColor];
    zipcodeLabel.font = [UIFont systemFontOfSize:22.0f];
    [CompanyView addSubview:zipcodeLabel];
    if (!zipcodeTf)
    zipcodeTf = [[UITextField alloc]initWithFrame:CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 320,  merchantW/2, 30)];
    zipcodeTf.text=zipcode;
    zipcodeTf.borderStyle = UITextBorderStyleRoundedRect;
    [CompanyView addSubview:zipcodeTf];
    //if (savemerchantDataBtn)
    savemerchantDataBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   savemerchantDataBtn.frame= CGRectMake(merchantW+100,380, 100, 40);
    [savemerchantDataBtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    savemerchantDataBtn.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [savemerchantDataBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [savemerchantDataBtn addTarget:self action:@selector(savemerchantDataClick) forControlEvents:UIControlEventTouchUpInside];
    //[addprinterdataView addSubview:printerNameButton];
    [savemerchantDataBtn setTitle:@"Save" forState:UIControlStateNormal];
    [CompanyView addSubview:savemerchantDataBtn];
    
}
-(void)savemerchantDataClick
{
      NSString *querySQL = [NSString stringWithFormat: @"SELECT merchant_name FROM merchant_info_table"];
    NSMutableArray *mertchantArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:mertchantArray];
    
    if ([mertchantArray count]>0){
        NSDictionary *dict=[mertchantArray objectAtIndex:0];
        
        NSString *merchentId=[dict objectForKey:@"merchant_name"];
        
        NSString *updateSQL = @"UPDATE merchant_info_table SET merchant_name=?, merchant_address=?,merchant_zipcode=?,merchant_address2=?,merchant_phone=? WHERE merchant_name=?";
        NSMutableArray *updteArray=[[NSMutableArray alloc]initWithObjects:merchantnameTf.text,addressTf.text,zipcodeTf.text,addressTf2.text,phNoTf.text, merchentId,nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:updteArray];
       
         NSString *querySQL = [NSString stringWithFormat:@"SELECT unique_id,created_timestamp,modified_timestamp,merchant_name,merchant_address,merchant_zipcode,server_local,merchant_address2,merchant_phone FROM merchant_info_table"];
        NSMutableArray *mertchantArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:mertchantArray];
       
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:mertchantArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet])
        {
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"merchant_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=merchant_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                CardConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [CardConnection start];
            }
        }
        
    }else{
        
        NSString *insertSQL =@"insert into merchant_info_table (unique_id,created_timestamp,modified_timestamp,merchant_name,merchant_address,merchant_zipcode,merchant_address2,merchant_phone) values(?,?,?,?,?,?,?,?)";
        NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],merchantnameTf.text,addressTf.text,zipcodeTf.text,addressTf2.text,phNoTf.text, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
        
        NSString *querySQL = [NSString stringWithFormat:@"SELECT unique_id,created_timestamp,modified_timestamp,merchant_name,merchant_address,merchant_zipcode,server_local,merchant_address2,merchant_phone FROM merchant_info_table"];
        NSMutableArray *mertchantArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:mertchantArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:mertchantArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"merchant_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=merchant_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                CardConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [CardConnection start];
                
            }
        }
    }
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Merchant Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    
}
-(void)SaveCompanyname
{
    
    SavecompanyAlert=[[UIAlertView alloc]initWithTitle:@"message" message:@"All local data will be deleted and You will be automatically loggedout?" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [SavecompanyAlert show];
    
   
    
}
-(void)SelectTheHomeimage
{
    if (!imgpicker)
    imgpicker=[[UIImagePickerController alloc]init];
    [imgpicker setEditing:YES];
    [imgpicker setDelegate:self];
    
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
    {
        
         [imgpicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }
    else
    {
        //camera Available
        [imgpicker setSourceType:UIImagePickerControllerSourceTypeCamera];

    }
    
    [self presentViewController:imgpicker animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    //// //NSLog(@"info is %@",info);
    selectedimage=[[UIImage alloc]init];
   selectedimage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    //[generalDataObject  setPosImage:selectedimage];
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
    // imageView is my image from camera
    NSData *imageData = UIImagePNGRepresentation(selectedimage);
   [imageData writeToFile:savedImagePath atomically:NO];
    
    HomeImageView.backgroundColor = [UIColor colorWithPatternImage:selectedimage];
    [imgpicker dismissViewControllerAnimated:YES completion:nil];
    
    
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [imgpicker dismissViewControllerAnimated:YES completion:nil];
    
}
-(void)Printerbarbutton
{
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [Printerbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    for (UITableView *tv in [addApplicationDataView subviews]) {
        [tv removeFromSuperview];
    }
    for (UIButton *btn in [addApplicationDataView subviews]) {
        [btn removeFromSuperview];
    }
    for (UIScrollView *sview in [ApplicationView subviews]) {
        [sview removeFromSuperview];
    }
    
 
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    
     if (!printerview)
    printerview=[[UIView alloc]init];
    printerview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [printerview setBackgroundColor:[UIColor whiteColor]];
    [printerview.layer setBorderWidth: 1.0];
    //[printerview.layer setCornerRadius:8.0f];
    [printerview.layer setMasksToBounds:YES];
    [printerview.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [mainview addSubview:printerview];
    
    
    //Divya Coding
    if (!addPrintButton)
    addPrintButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [addPrintButton setTitle:@"Add Printer" forState:UIControlStateNormal];
    CGFloat addbuttonwidth=(printerview.frame.size.width-10)/2;
    addPrintButton.frame=CGRectMake(10, 10, addbuttonwidth, 40);
    [addPrintButton setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    //addtaxBtn.layer.cornerRadius=8;
    [addPrintButton addTarget:self action:@selector(addPrintbutton) forControlEvents:UIControlEventTouchUpInside];
    [printerview addSubview:addPrintButton];
    
     if (!editPrinterButton)
    editPrinterButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [editPrinterButton setTitle:@"View and Edit Printer" forState:UIControlStateNormal];
    editPrinterButton.frame=CGRectMake(addPrintButton.frame.size.width, 10, addbuttonwidth, 40);
    //editTaxButton.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [editPrinterButton setBackgroundColor:[UIColor whiteColor]];
    [editPrinterButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [editPrinterButton addTarget:self action:@selector(editPrintbutton) forControlEvents:UIControlEventTouchUpInside];
    [printerview addSubview: editPrinterButton];
    
    if (!addprinterdataView)
    addprinterdataView=[[UIScrollView alloc]init];
    addprinterdataView.frame=CGRectMake(10, 10+addPrintButton.frame.size.height, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
    if (isLandScope){
         addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2+200);
    }else{
        addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2);
   }
    [addprinterdataView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    //addprinterdataView.layer.cornerRadius=8;
    [printerview addSubview:addprinterdataView];
    
  
    if (!editPrinterTable)
    editPrinterTable=[[UITableView alloc]init];
    [editPrinterTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    editPrinterTable.frame=CGRectMake(10, addPrintButton.frame.size.height+10, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
    editPrinterTable.delegate=self;
    editPrinterTable.dataSource=self;
    
//Divya date 13th Coding
    
    CGFloat Printerw=addprinterdataView.frame.size.width/3;
    if (!printCharLabel)
    printCharLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 20, Printerw, 30)];
    printCharLabel.text= @"Printer Charecter";
    printCharLabel.backgroundColor=[UIColor clearColor];
    printCharLabel.textColor=[UIColor whiteColor];
    printCharLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:printCharLabel];
     if (!printerCharTF)
    printerCharTF = [[UITextView alloc]initWithFrame:CGRectMake(Printerw, 55, Printerw, 30)];
    //printerCharTF.borderStyle = UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:printerCharTF];
    
     if (!fontLabel)
    fontLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 85, Printerw, 30)];
    fontLabel.text= @"Font";
     fontLabel.backgroundColor=[UIColor clearColor];
    fontLabel.textColor=[UIColor whiteColor];
     fontLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:fontLabel];
    if (!fontButton)
    fontButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    fontButton.frame=CGRectMake(Printerw, 115, 200, 30);
    [fontButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    fontButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [fontButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [fontButton addTarget:self action:@selector(FontsizesetClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:fontButton];
    if (!alignLineSpaLabel)
    alignLineSpaLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 145, Printerw, 30)];
    alignLineSpaLabel.text= @"Align";
     alignLineSpaLabel.backgroundColor=[UIColor clearColor];
    alignLineSpaLabel.textColor=[UIColor whiteColor];
    alignLineSpaLabel.font = [UIFont systemFontOfSize:20.0f];
    
    [addprinterdataView addSubview:alignLineSpaLabel];
    if (!alignLineSpaButton)
    alignLineSpaButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    alignLineSpaButton.frame=CGRectMake(Printerw, 175, 200, 30);
    [alignLineSpaButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    alignLineSpaButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [alignLineSpaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [alignLineSpaButton addTarget:self action:@selector(alignLineSpaceClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:alignLineSpaButton];
      if (!langLabel)
    langLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 205, Printerw, 30)];
    langLabel.text=@"Language";
     langLabel.backgroundColor=[UIColor clearColor];
    langLabel.textColor=[UIColor whiteColor];
    langLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:langLabel];
    if (!languageButton)
    languageButton  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    languageButton.frame=CGRectMake(Printerw, 235, 200, 30);
    [languageButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    languageButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [languageButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [languageButton addTarget:self action:@selector(languageButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:languageButton];
    
    //    langTF = [[UITextField alloc]initWithFrame:CGRectMake(30, 235, 200, 30)];
    //    langTF.borderStyle = UITextBorderStyleRoundedRect;
    //    [addprinterdataView addSubview:langTF];
    
    
     if (!sizeLabel)
    sizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 265, Printerw, 30)];
    sizeLabel.text=@"Size(width,Height)";
     sizeLabel.backgroundColor=[UIColor clearColor];
    sizeLabel.textColor=[UIColor whiteColor];
    sizeLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:sizeLabel];
    if (!sizeButton)
    sizeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    sizeButton.frame=CGRectMake(Printerw, 295, Printerw/2, 30);
    [sizeButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    sizeButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [sizeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sizeButton addTarget:self action:@selector(sizeClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:sizeButton];
     if (!widthButton)
    widthButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    widthButton.frame=CGRectMake(Printerw+sizeButton.frame.size.width+5, 295, Printerw/2, 30);
    [widthButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    widthButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [widthButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [widthButton addTarget:self action:@selector(widthClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:widthButton];
    
    if (!styleLabel)
    styleLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 325, Printerw/2, 30)];
    styleLabel.text = @"Style";
     styleLabel.backgroundColor=[UIColor clearColor];
    styleLabel.textColor=[UIColor whiteColor];
    styleLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:styleLabel];
    
     if (!boldLabel)
    boldLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw+10, 355, Printerw/2, 30)];
    boldLabel.text = @"Bold";
      boldLabel.backgroundColor=[UIColor clearColor];
    boldLabel.textColor=[UIColor whiteColor];
    boldLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:boldLabel];
    
    if (!boldSwitch)
    boldSwitch=[[UISwitch alloc]initWithFrame:CGRectMake(Printerw+10+boldLabel.frame.size.width, 355, 100, 30)];
    [boldSwitch addTarget:self action:@selector(boldSwitchClick:) forControlEvents:UIControlEventValueChanged];
    [addprinterdataView addSubview:boldSwitch];
     if (!underLineLabel)
    underLineLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw+10, 385, Printerw, 30)];
    underLineLabel.text=@"UnderLine";
      underLineLabel.backgroundColor=[UIColor clearColor];
    underLineLabel.textColor=[UIColor whiteColor];
    underLineLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:underLineLabel];
    if (!underlineSwitch)
    underlineSwitch= [[UISwitch alloc]initWithFrame:CGRectMake(Printerw+10+boldLabel.frame.size.width, 390, 100, 30)];
    [underlineSwitch addTarget:self action:@selector(underlineSwitchClick:) forControlEvents:UIControlEventValueChanged];
    [addprinterdataView addSubview:underlineSwitch];
    if (!xPositionLabel)
    xPositionLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 415, Printerw, 30)];
    xPositionLabel.text= @"X Position";
     xPositionLabel.backgroundColor=[UIColor clearColor];
    xPositionLabel.textColor=[UIColor whiteColor];
    xPositionLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:xPositionLabel];
     if (!xPositionTF)
    xPositionTF = [[UITextField alloc]initWithFrame:CGRectMake(Printerw, 445, Printerw, 30)];
    xPositionTF.borderStyle=UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:xPositionTF];
    if (!feedUnitLabel)
    feedUnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 475, Printerw, 30)];
    feedUnitLabel.text= @"Feed Unit";
    feedUnitLabel.backgroundColor=[UIColor clearColor];
    feedUnitLabel.textColor=[UIColor whiteColor];
    feedUnitLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:feedUnitLabel];
    if (!feedUnitTF)
    feedUnitTF = [[UITextField alloc]initWithFrame:CGRectMake(Printerw, 505, Printerw, 30)];
    feedUnitTF.borderStyle=UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:feedUnitTF];
    if (!PrinterTypeLabel)
    PrinterTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 535, Printerw, 30)];
    PrinterTypeLabel.text=@"Printer Type";
    PrinterTypeLabel.backgroundColor=[UIColor clearColor];
    PrinterTypeLabel.textColor=[UIColor whiteColor];
    PrinterTypeLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:PrinterTypeLabel];
    if (!PrinterTypeBtn)
    PrinterTypeBtn  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    PrinterTypeBtn.frame=CGRectMake(Printerw, 565, 200, 30);
    [PrinterTypeBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    PrinterTypeBtn.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [PrinterTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [PrinterTypeBtn addTarget:self action:@selector(printerTypeClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:PrinterTypeBtn];
     if (!wifiLabel)
    wifiLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw+Printerw+5, 565, 50, 30)];
    wifiLabel.text=@"wifi";
    wifiLabel.backgroundColor=[UIColor clearColor];
    wifiLabel.textColor=[UIColor whiteColor];
    wifiLabel.font = [UIFont systemFontOfSize:20.0f];
    wifiLabel.hidden=YES;
    [addprinterdataView addSubview:wifiLabel];
    if (!wifi_Switch)
    wifi_Switch=[[UISwitch alloc]initWithFrame:CGRectMake(Printerw+Printerw+55, 565, 100, 30)];
    [wifi_Switch addTarget:self action:@selector(wifiSwitchClick:) forControlEvents:UIControlEventValueChanged];
    wifi_Switch.hidden=YES;
    [addprinterdataView addSubview:wifi_Switch];
    btLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw+Printerw+125, 565, 100, 30)];
    btLabel.text=@"Bluetooth";
    btLabel.backgroundColor=[UIColor clearColor];
    btLabel.textColor=[UIColor whiteColor];
    btLabel.font = [UIFont systemFontOfSize:20.0f];
     btLabel.hidden=YES;
    [addprinterdataView addSubview:btLabel];
  
     if (!PrinterNameLabel)
    PrinterNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 595, Printerw, 30)];
    PrinterNameLabel.text=@"Printer Name";
      PrinterNameLabel.backgroundColor=[UIColor clearColor];
    PrinterNameLabel.textColor=[UIColor whiteColor];
    PrinterNameLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:PrinterNameLabel];
    if (!printerNameButton)
    printerNameButton  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    printerNameButton.frame=CGRectMake(Printerw,625, 200, 30);
    [printerNameButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    printerNameButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [printerNameButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [printerNameButton addTarget:self action:@selector(printerNameClick) forControlEvents:UIControlEventTouchUpInside];
    [addprinterdataView addSubview:printerNameButton];
     if (!printerIDLabel)
    printerIDLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 655, Printerw, 30)];
    printerIDLabel.text = @"Printer ID";
    printerIDLabel.backgroundColor=[UIColor clearColor];
    printerIDLabel.textColor=[UIColor whiteColor];
    printerIDLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:printerIDLabel];
    if (!printeridTF)
    printeridTF = [[UITextField alloc]initWithFrame:CGRectMake(Printerw, 685, Printerw, 30)];
    printeridTF.borderStyle= UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:printeridTF];
    if (!Printer1Label)
    Printer1Label=[[UILabel alloc] init];
    Printer1Label.frame=CGRectMake(Printerw+Printerw+10, 645, 150, 100);
    [Printer1Label setFont:[UIFont systemFontOfSize:20.0f]];
    [Printer1Label setBackgroundColor:[UIColor clearColor]];
    [Printer1Label setTextColor:[UIColor blackColor]];
    [Printer1Label setText:@"printer1  will be default printer."];
    Printer1Label.lineBreakMode = NSLineBreakByWordWrapping;
    Printer1Label.numberOfLines = 2;
    [Printer1Label setTextAlignment:NSTextAlignmentLeft];
    [addprinterdataView addSubview:Printer1Label];
    
     if (!ipAddressLabel)
    ipAddressLabel = [[UILabel alloc]initWithFrame:CGRectMake(Printerw, 715, Printerw, 30)];
    ipAddressLabel.text= @"IP Address/PortName";
     ipAddressLabel.backgroundColor=[UIColor clearColor];
    ipAddressLabel.textColor=[UIColor whiteColor];
    ipAddressLabel.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:ipAddressLabel];
    if (!ipAddressTF)
    ipAddressTF = [[UITextField alloc]initWithFrame:CGRectMake(Printerw, 745, Printerw, 30)];
    ipAddressTF.borderStyle= UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:ipAddressTF];
    
    if (!fontArray)
    {
    fontArray = [[NSArray alloc]initWithObjects:@"A",@"B",@"C", nil];
    alignLineSpacArray = [[NSArray alloc]initWithObjects:@"Left",@"Right",@"Center", nil];
    sizeWidthArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"2",@"3",@"4",@"5",@"6",@"7",@"8", nil];
    sizeheightArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"2",@"3",@"4",@"5",@"6",@"7",@"8", nil];
   
    langArray = [[NSArray alloc]initWithObjects:@"ANK",@"JAPANESE",@"SIMPLIFIED CHINESE",@"TRADITIONAL CHINESE", nil];
    }
    
    if (!fontTableView)
    fontTableView = [[UITableView alloc] initWithFrame:CGRectMake(Printerw, 116, 200, 100) style:UITableViewStylePlain];
    fontTableView.backgroundColor=[UIColor whiteColor];
    fontTableView.delegate = self;
    fontTableView.dataSource = self;
    fontTableView.scrollEnabled = YES;
    fontTableView.hidden=YES;
    [fontTableView.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [fontTableView.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:fontTableView];
    
    
    if (!alignLineSpaTV)
    alignLineSpaTV = [[UITableView alloc] initWithFrame:CGRectMake(Printerw, 178, 200, 100) style:UITableViewStylePlain];
    alignLineSpaTV.backgroundColor=[UIColor whiteColor];
    alignLineSpaTV.delegate = self;
    alignLineSpaTV.dataSource = self;
    alignLineSpaTV.scrollEnabled = YES;
    alignLineSpaTV.hidden=YES;
    [alignLineSpaTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [alignLineSpaTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:alignLineSpaTV];
    if (!languageTV)
    languageTV = [[UITableView alloc]initWithFrame:CGRectMake(Printerw, 238, 200, 100) style:UITableViewStylePlain];
    languageTV.backgroundColor=[UIColor whiteColor];
    languageTV.delegate = self;
    languageTV.dataSource = self;
    languageTV.scrollEnabled = YES;
    languageTV.hidden=YES;
    [languageTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [languageTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:languageTV];
    
    if (!sizeWidthTV)
    sizeWidthTV = [[UITableView alloc] initWithFrame:CGRectMake(Printerw, 298, Printerw/2, 100) style:UITableViewStylePlain];
    sizeWidthTV.backgroundColor=[UIColor whiteColor];
    sizeWidthTV.delegate = self;
    sizeWidthTV.dataSource = self;
    sizeWidthTV.scrollEnabled = YES;
    sizeWidthTV.hidden=YES;
    [sizeWidthTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [sizeWidthTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:sizeWidthTV];
    if (!sizeHeightTV)
    sizeHeightTV = [[UITableView alloc] initWithFrame:CGRectMake(Printerw+sizeButton.frame.size.width+5, 298, Printerw/2, 100) style:UITableViewStylePlain];
    sizeHeightTV.backgroundColor=[UIColor whiteColor];
    sizeHeightTV.delegate = self;
    sizeHeightTV.dataSource = self;
    sizeHeightTV.scrollEnabled = YES;
    sizeHeightTV.hidden=YES;
    [sizeHeightTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [sizeHeightTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:sizeHeightTV];
    if (!PrintertypesArray)
    PrintertypesArray=[[NSMutableArray alloc]initWithObjects:@"EPSON",@"STAR", nil];
    if (!PrinterTypesTable)
    PrinterTypesTable = [[UITableView alloc] initWithFrame:CGRectMake(Printerw, 568, 200, 100) style:UITableViewStylePlain];
    PrinterTypesTable.backgroundColor=[UIColor whiteColor];
    PrinterTypesTable.delegate = self;
    PrinterTypesTable.dataSource = self;
    PrinterTypesTable.scrollEnabled = YES;
    PrinterTypesTable.hidden=YES;
    [PrinterTypesTable.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [PrinterTypesTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:PrinterTypesTable];
    if (!printerNameTV)
    printerNameTV = [[UITableView alloc] initWithFrame:CGRectMake(Printerw, 628, 200, 100) style:UITableViewStylePlain];
    printerNameTV.backgroundColor=[UIColor whiteColor];
    printerNameTV.delegate = self;
    printerNameTV.dataSource = self;
    printerNameTV.scrollEnabled = YES;
    printerNameTV.hidden=YES;
    [printerNameTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [printerNameTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addprinterdataView addSubview:printerNameTV];
   
    if (!LignSpacelbl)
    LignSpacelbl = [[UILabel alloc]initWithFrame:CGRectMake(Printerw,775, Printerw, 30)];
    LignSpacelbl.text= @"Line Spacing";
    LignSpacelbl.backgroundColor=[UIColor clearColor];
    LignSpacelbl.textColor=[UIColor whiteColor];
    LignSpacelbl.font = [UIFont systemFontOfSize:20.0f];
    [addprinterdataView addSubview:LignSpacelbl];
    if (!alignLineSpaTF)
    alignLineSpaTF = [[UITextField alloc]initWithFrame:CGRectMake(Printerw, 805, Printerw, 30)];
    alignLineSpaTF.borderStyle= UITextBorderStyleRoundedRect;
    [addprinterdataView addSubview:alignLineSpaTF];
    if (!saveButton)
    saveButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    saveButton.frame= CGRectMake(Printerw,850, Printerw, 40);
    [saveButton setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    saveButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [saveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [saveButton addTarget:self action:@selector(savePrinterDataClick) forControlEvents:UIControlEventTouchUpInside];
    //[addprinterdataView addSubview:printerNameButton];
    [saveButton setTitle:@"Save" forState:UIControlStateNormal];
    [addprinterdataView addSubview:saveButton];
    Bold=@"0";
    Underline=@"0";
    SearchPrinterStr=@"TCP";
    

}

-(void)addPrintbutton
{
    [editPrinterButton setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [addPrintButton setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [editPrinterButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [addPrintButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [editPrinterTable removeFromSuperview];
    [printerview addSubview:addprinterdataView];
    
    printcharArray = nil;
    FontsArray = nil;
    AlignsArray = nil;
    languagesArray = nil;
    WidthsArray = nil;
    HeightsArray = nil;
    unitsArray = nil;
    boldsArray = nil;
    UnderlinesArray = nil;
    XpossArray = nil;
    
    spacingsArray = nil;
    printernamesArray = nil;
    IpAddsArray = nil;
    PrinterIdsArray = nil;
    DbPrinterTypesArray=nil;
}
-(void)editPrintbutton
{
   
    
     [addPrintButton setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [addPrintButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [addPrintButton setBackgroundColor:[UIColor whiteColor]];
    [addPrintButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [editPrinterButton setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    //addtaxBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    
    [editPrinterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self GetprinterDatamethod];
    
    [addprinterdataView removeFromSuperview];
    [printerview addSubview:editPrinterTable];
}
-(void) GetprinterDatamethod
{
        printcharArray = [[NSMutableArray alloc]init];
        FontsArray = [[NSMutableArray alloc]init];
        AlignsArray = [[NSMutableArray alloc]init];
        languagesArray = [[NSMutableArray alloc]init];
        WidthsArray = [[NSMutableArray alloc]init];
        HeightsArray = [[NSMutableArray alloc]init];
        unitsArray = [[NSMutableArray alloc]init];
        boldsArray = [[NSMutableArray alloc]init];
        UnderlinesArray = [[NSMutableArray alloc]init];
        XpossArray = [[NSMutableArray alloc]init];
        spacingsArray = [[NSMutableArray alloc]init];
        printernamesArray = [[NSMutableArray alloc]init];
        IpAddsArray = [[NSMutableArray alloc]init];
        PrinterIdsArray = [[NSMutableArray alloc]init];
        DbPrinterTypesArray=[[NSMutableArray alloc]init];
        searchPrinterArray=[[NSMutableArray alloc]init];
    
    NSString *querySQL5 = [NSString stringWithFormat: @"SELECT headlines, language,unit,spacing,fontsize,align,Wsize,Hsize,bold,underline,Xposition,printname,print_id,ipaddress,created_timestamp,modified_timestamp,unique_id,printer_type,searchprinter FROM printer"];
    NSMutableArray *printersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printersArray];
    
    @autoreleasepool {
        for (NSDictionary *myDict in printersArray)
        {
            [printcharArray addObject:[myDict objectForKey:@"headlines"]];
            [FontsArray addObject:[myDict objectForKey:@"fontsize"]];
            [AlignsArray addObject:[myDict objectForKey:@"align"]];
            [languagesArray addObject:[myDict objectForKey:@"language"]];
            [WidthsArray addObject:[myDict objectForKey:@"Wsize"]];
            [HeightsArray addObject:[myDict objectForKey:@"Hsize"]];
            [boldsArray addObject:[myDict objectForKey:@"bold"]];
            [UnderlinesArray addObject:[myDict objectForKey:@"underline"]];
            [XpossArray addObject:[myDict objectForKey:@"Xposition"]];
            [unitsArray addObject:[myDict objectForKey:@"unit"]];
            
            [spacingsArray addObject:[myDict objectForKey:@"spacing"]];
            [printernamesArray addObject:[myDict objectForKey:@"printname"]];
            [IpAddsArray addObject:[myDict objectForKey:@"ipaddress"]];
            [PrinterIdsArray addObject:[myDict objectForKey:@"print_id"]];
            [DbPrinterTypesArray addObject:[myDict objectForKey:@"printer_type"]];
            [searchPrinterArray addObject:[myDict objectForKey:@"searchprinter"]];
            
        }
    }
   
}

-(void)wifiSwitchClick:(UISwitch *)sender
{
    if (sender.on){
        [sender setOn:FALSE animated:YES];
          SearchPrinterStr=@"TCP";
        
    }else{
          [sender setOn:TRUE animated:YES];
          SearchPrinterStr=@"BT";
    }
}
-(void)boldSwitchClick: (UISwitch *)sender
{
    if (sender.on){
        Bold=@"0";
         [sender setOn:FALSE animated:YES];
        
    }else{
        Bold=@"1";
          [sender setOn:TRUE animated:YES];
    }
    
}
-(void)underlineSwitchClick : (UISwitch *)sender
{
    if (sender.on){
        Underline=@"0";
         [sender setOn:FALSE animated:YES];
    }else{
        Underline=@"1";
         [sender setOn:TRUE animated:YES];
    }
}
-(void)alignLineSpaceClick
{
    if (alignLineSpaTV.hidden==1){
        [alignLineSpaTV setHidden:NO];
        
        languageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (alignLineSpaTV.hidden==0){
        [alignLineSpaTV setHidden:YES];
        
        languageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
    
}
-(void)languageButtonClick
{
    if (languageTV.hidden==1){
        
        [languageTV setHidden:NO];
        
        sizeButton.hidden=YES;
        
        //languageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (languageTV.hidden==0){
        [languageTV setHidden:YES];
        
        sizeButton.hidden=NO;
        
        //languageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
    
}
-(void)sizeClick
{
    if (sizeWidthTV.hidden==1){
        
        [sizeWidthTV setHidden:NO];
        
        //sizeButton.hidden=YES;
        
        //languageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (sizeWidthTV.hidden==0){
        [sizeWidthTV setHidden:YES];
        
        //sizeButton.hidden=YES;
        
        //languageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
    
}
-(void)widthClick
{
    if (sizeHeightTV.hidden==1){
        
        [sizeHeightTV setHidden:NO];
        
        //sizeButton.hidden=YES;
        
        //languageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (sizeHeightTV.hidden==0){
        [sizeHeightTV setHidden:YES];
        
        //sizeButton.hidden=YES;
        
        //languageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
}
-(void)FontsizesetClick
{
    
    if (fontTableView.hidden==1){
        [fontTableView setHidden:NO];
        
        alignLineSpaButton.hidden=YES;
        
    }else if (fontTableView.hidden==0){
        [fontTableView setHidden:YES];
        
        alignLineSpaButton.hidden=NO;
    }
    
}
-(void)printerTypeClick
{
    if (PrinterTypesTable.hidden==1){
        [PrinterTypesTable setHidden:NO];
        
    }else if (PrinterTypesTable.hidden==0){
        [PrinterTypesTable setHidden:YES];
    }
}
-(void)printerNameClick
{
    if (printerNameTV.hidden==1){
        [printerNameTV setHidden:NO];
        
    }else if (printerNameTV.hidden==0)
    {
        [printerNameTV setHidden:YES];
    }
}
-(void)savePrinterDataClick
{
    NSString *querySQL5 = [NSString stringWithFormat: @"SELECT print_id FROM printer"];
    NSMutableArray *printerDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printerDataArray];
    
    NSString *Font=[NSString stringWithFormat:@"%@",fontButton.titleLabel.text];
      NSString *align=[NSString stringWithFormat:@"%@",alignLineSpaButton.titleLabel.text];
      NSString *language=[NSString stringWithFormat:@"%@",languageButton.titleLabel.text];
      NSString *Swidth=[NSString stringWithFormat:@"%@",sizeButton.titleLabel.text];
      NSString *Sheight=[NSString stringWithFormat:@"%@",widthButton.titleLabel.text];
      NSString *printername=[NSString stringWithFormat:@"%@",printerNameButton.titleLabel.text];
     NSString *printerType=[NSString stringWithFormat:@"%@",PrinterTypeBtn.titleLabel.text];
    PrinterIdsArray=[[NSMutableArray alloc]init];
    
    for (NSDictionary *myDict in printerDataArray)
    {
        [PrinterIdsArray addObject:[myDict objectForKey:@"print_id"]];
    }
    
    NSUInteger objIdx = [PrinterIdsArray containsObject:printeridTF.text];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
     NSString *insertSQL =@"insert into printer (headlines, language,unit,spacing,fontsize,align,Wsize,Hsize,bold,underline,Xposition,printname,print_id,ipaddress,created_timestamp,modified_timestamp,unique_id,printer_type,searchprinter) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:printerCharTF.text,language,feedUnitTF.text,alignLineSpaTF.text,Font,align,Swidth,Sheight,Bold,Underline,xPositionTF.text,printername,printeridTF.text,ipAddressTF.text,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],[generalDataObject  genRandStringLength:20],printerType,SearchPrinterStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
        
        insertSQL=nil;
  
        printerCharTF.text=@"";feedUnitTF.text=@"";alignLineSpaTF.text=@"";xPositionTF.text=@"";printeridTF.text=@"";ipAddressTF.text=@"";
     [editPrinterTable reloadData];
         // //NSLog(@"%@",insertSQL);
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Printer data successfully saved." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Printer ID already exist change the Printer ID" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    }
     SearchPrinterStr=@"TCP";
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
    //Use this method insted of addTarget:
    
    if (textField.tag == 100)
    {
        
        columnnamestr=textField.text;
    }
    if (textField.tag == 101)
    {
        columnsizeStr=textField.text;
    }
    if (textField.tag == 102)
    {
        feedstr=textField.text;
    }
    if (textField.tag == 103)
    {
        
        spacingstr=textField.text;
    }
}

-(void)Alignclick
{
    if (aligndataTable.hidden==1){
        
        [aligndataTable setHidden:NO];
        
        fontsizeBtn.hidden=YES;
        printermethodBtn.hidden=YES;
        
    }else if (aligndataTable.hidden==0){
        [aligndataTable setHidden:YES];
        
        fontsizeBtn.hidden=NO;
        printermethodBtn.hidden=NO;
    }
   
    // //NSLog(@"called");
}

-(void)printmethodClick
{
    if (printermethodsTable.hidden==1){
        [printermethodsTable setHidden:NO];
        printeridField.hidden=YES;
        printernameField.hidden=YES;
        
    }else if (printermethodsTable.hidden==0){
        [printermethodsTable setHidden:YES];
        printeridField.hidden=NO;
        printernameField.hidden=NO;
    }
}

-(void)Getprinterstatus
{
    
}
-(void)paymentbarbutton
{
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [paymentbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    
    //payment view
    if (!paymentview)
    paymentview=[[UIView alloc]init];
    paymentview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [paymentview setBackgroundColor:[UIColor whiteColor]];
    [paymentview.layer setBorderWidth: 1.0];
    //[paymentview.layer setCornerRadius:8.0f];
    [paymentview.layer setMasksToBounds:YES];
    [paymentview.layer setBorderColor:[[UIColor blackColor] CGColor]];
    //paymentview.layer.cornerRadius=8;
    [mainview addSubview:paymentview];
   
    addpaymentBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [addpaymentBtn setTitle:@"Add Payment" forState:UIControlStateNormal];
    [addpaymentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    CGFloat addbuttonwidth=(paymentview.frame.size.width-10)/2;
    addpaymentBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
    [addpaymentBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [addpaymentBtn addTarget:self action:@selector(addpaymentClick) forControlEvents:UIControlEventTouchUpInside];
    [paymentview addSubview:addpaymentBtn];
   
    editpaymentBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [editpaymentBtn setTitle:@"View and Edit Payment" forState:UIControlStateNormal];
    editpaymentBtn.frame=CGRectMake(addpaymentBtn.frame.size.width, 10, addbuttonwidth, 40);
    //editTaxButton.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [editpaymentBtn setBackgroundColor:[UIColor whiteColor]];
    [editpaymentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [editpaymentBtn addTarget:self action:@selector(editpaymenClick) forControlEvents:UIControlEventTouchUpInside];
    [paymentview addSubview: editpaymentBtn];
    
    //add payment view
     if (!AddpaymentView)
    AddpaymentView=[[UIView alloc]init];
    AddpaymentView.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
    [AddpaymentView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    //AddpaymentView.layer.cornerRadius=8;
    [paymentview addSubview:AddpaymentView];
    
    CGFloat labelwidth=(AddpaymentView.frame.size.width)/2;
    CGFloat x=(labelwidth/2)+20;
    if (!paymentnamelbl)
    paymentnamelbl=[[UILabel alloc]init];
    paymentnamelbl.frame=CGRectMake(x,50 ,100, 50);
    [paymentnamelbl setText:@"Name"];
    [paymentnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [paymentnamelbl setBackgroundColor:[UIColor clearColor]];
    [paymentnamelbl setTextColor:[UIColor whiteColor]];
    [AddpaymentView addSubview:paymentnamelbl];
    if (!paymentnameField)
    paymentnameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    paymentnameField.frame=CGRectMake(x+paymentnamelbl.frame.size.width+10, 58, 230, 40);
    paymentnameField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    paymentnameField.leftView = paddingview;
    paymentnameField.leftViewMode = UITextFieldViewModeAlways;
    paymentnameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [paymentnameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [paymentnameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddpaymentView addSubview:paymentnameField];
    if (!paymenttaxlbl)
    paymenttaxlbl=[[UILabel alloc]init];
    paymenttaxlbl.frame=CGRectMake(x,103 ,100, 50);
    [paymenttaxlbl setText:@"Tax"];
    [paymenttaxlbl setBackgroundColor:[UIColor clearColor]];
    [paymenttaxlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [paymenttaxlbl setTextColor:[UIColor whiteColor]];
    [AddpaymentView addSubview:paymenttaxlbl];
    if (!paymentenableradioBtn)
    paymentenableradioBtn = [[UIButton alloc] initWithFrame:CGRectMake(x+paymentnamelbl.frame.size.width+10,120, 20, 20)];
    [paymentenableradioBtn setTag:0];
    [paymentenableradioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
    [paymentenableradioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    
    [paymentenableradioBtn addTarget:self action:@selector(radiobuttonSelected1:) forControlEvents:UIControlEventTouchUpInside];
    if (!paymentdisableradioBtn)
    paymentdisableradioBtn = [[UIButton alloc] initWithFrame:CGRectMake(x+paymentnamelbl.frame.size.width+10,155, 20, 20)];
    [paymentdisableradioBtn setTag:1];
    [paymentdisableradioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
    [paymentdisableradioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    [paymentdisableradioBtn addTarget:self action:@selector(radiobuttonSelected1:) forControlEvents:UIControlEventTouchUpInside];
    [paymentenableradioBtn setSelected:YES];
    [AddpaymentView addSubview:paymentenableradioBtn];
    [AddpaymentView addSubview:paymentdisableradioBtn];
    if (!enablepaymentlbl)
    enablepaymentlbl=[[UILabel alloc]init];
    enablepaymentlbl.frame=CGRectMake(x+paymentnamelbl.frame.size.width+40,113 ,100, 30);
    [enablepaymentlbl setText:@"Enable"];
    [enablepaymentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [enablepaymentlbl setBackgroundColor:[UIColor clearColor]];
    [enablepaymentlbl setTextColor:[UIColor whiteColor]];
    [AddpaymentView addSubview:enablepaymentlbl];
    if (!disablepaymentlbl)
    disablepaymentlbl=[[UILabel alloc]init];
    disablepaymentlbl.frame=CGRectMake(x+paymentnamelbl.frame.size.width+40,151 ,100, 30);
    [disablepaymentlbl setText:@"Disable"];
    [disablepaymentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [disablepaymentlbl setBackgroundColor:[UIColor clearColor]];
    [disablepaymentlbl setTextColor:[UIColor whiteColor]];
    [AddpaymentView addSubview:disablepaymentlbl];
    @autoreleasepool {
        savepaymentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        savepaymentBtn.frame=CGRectMake(x+paymentnamelbl.frame.size.width-40, 220, 80, 30);
        [savepaymentBtn addTarget:self action:@selector(SavepaymentClick) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [savepaymentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [savepaymentBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [AddpaymentView addSubview:savepaymentBtn];
        
        cancelpaymentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        cancelpaymentBtn.frame=CGRectMake(x+paymentnamelbl.frame.size.width+100, 220, 80, 30);
        [cancelpaymentBtn addTarget:self action:@selector(CancelpaymentClick) forControlEvents:UIControlEventTouchUpInside];
        [cancelpaymentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [cancelpaymentBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        
        [AddpaymentView addSubview:cancelpaymentBtn];
    }
   
    
    if (!PaymentTable)
    PaymentTable=[[UITableView alloc]init];
    [PaymentTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    PaymentTable.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
    PaymentTable.delegate=self;
    PaymentTable.dataSource=self;
    
    
}
-(void)taxbarbutton
{
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [taxbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
   
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    
     if (!TaxView)
    TaxView=[[UIView alloc]init];
    TaxView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [TaxView setBackgroundColor:[UIColor whiteColor]];
    [TaxView.layer setBorderWidth: 1.0];
   // [TaxView.layer setCornerRadius:8.0f];
    [TaxView.layer setMasksToBounds:YES];
    [TaxView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    
    //TaxView.layer.cornerRadius=8;
    [mainview addSubview:TaxView];
    
    @autoreleasepool {
        addtaxBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [addtaxBtn setTitle:@"Add Tax" forState:UIControlStateNormal];
        CGFloat addbuttonwidth=(TaxView.frame.size.width-10)/2;
        addtaxBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        [addtaxBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
        [addtaxBtn addTarget:self action:@selector(addtaxbutton) forControlEvents:UIControlEventTouchUpInside];
        [TaxView addSubview:addtaxBtn];
        
        editTaxButton=[UIButton buttonWithType:UIButtonTypeCustom];
        [editTaxButton setTitle:@"View and Edit Tax" forState:UIControlStateNormal];
        editTaxButton.frame=CGRectMake(addtaxBtn.frame.size.width, 10, addbuttonwidth, 40);
        //editTaxButton.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
        [editTaxButton setBackgroundColor:[UIColor whiteColor]];
        [editTaxButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [editTaxButton addTarget:self action:@selector(edittaxbutton) forControlEvents:UIControlEventTouchUpInside];
        [TaxView addSubview: editTaxButton];
    }
    
    //add Tax view
     if (!AddTaxView)
    AddTaxView=[[UIView alloc]init];
    //CGFloat addviewwidth=(TaxView.frame.size.width/2);
    //CGFloat x=addviewwidth/2-10;
    AddTaxView.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
    [AddTaxView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [TaxView addSubview:AddTaxView];
    
    CGFloat labelwidth=(AddTaxView.frame.size.width)/2;
    CGFloat x=(labelwidth/2)+20;
     if (!namelabel)
    namelabel=[[UILabel alloc]init];
    namelabel.frame=CGRectMake(x,50 ,100, 50);
    [namelabel setText:@"Name"];
    [namelabel setFont:[UIFont systemFontOfSize:25.0f]];
    [namelabel setBackgroundColor:[UIColor clearColor]];
    [namelabel setTextColor:[UIColor whiteColor]];
    [AddTaxView addSubview:namelabel];
     if (!nameTextfield)
    nameTextfield=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    nameTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 60, 200, 30);
    nameTextfield.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    nameTextfield.leftView = paddingview;
    nameTextfield.leftViewMode = UITextFieldViewModeAlways;
      nameTextfield.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [nameTextfield setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [nameTextfield setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddTaxView addSubview:nameTextfield];
     if (!RateLabel)
    RateLabel=[[UILabel alloc]init];
    RateLabel.frame=CGRectMake(x,150 ,100, 50);
    [RateLabel setText:@"Rate"];
    [RateLabel setBackgroundColor:[UIColor clearColor]];
     [RateLabel setFont:[UIFont systemFontOfSize:25.0f]];
    [RateLabel setTextColor:[UIColor whiteColor]];
    [AddTaxView addSubview:RateLabel];
     if (!RateTextfield)
    RateTextfield=[[UITextField alloc] init];
    RateTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 160, 200, 30);
    RateTextfield.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    RateTextfield.leftView = paddingview2;
    RateTextfield.leftViewMode = UITextFieldViewModeAlways;
    [RateTextfield setAutocorrectionType:UITextAutocorrectionTypeNo];
     //[RateTextfield setBorderStyle:UITextBorderStyleRoundedRect];
     [RateTextfield setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [RateTextfield setKeyboardType:UIKeyboardTypeNumberPad];
      RateTextfield.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [AddTaxView addSubview:RateTextfield];
    @autoreleasepool {
        SaveTaxButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        SaveTaxButton.frame=CGRectMake(x+namelabel.frame.size.width-20, 240, 80, 30);
        [SaveTaxButton addTarget:self action:@selector(SaveTax) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveTaxButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveTaxButton setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [AddTaxView addSubview:SaveTaxButton];
        
        CancelTaxButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelTaxButton.frame=CGRectMake(x+namelabel.frame.size.width+80, 240, 80, 30);
        [CancelTaxButton addTarget:self action:@selector(Canceltax) forControlEvents:UIControlEventTouchUpInside];
        [CancelTaxButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [CancelTaxButton setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        
        [AddTaxView addSubview:CancelTaxButton];
    }
   
    if (!edittaxTable)
    edittaxTable=[[UITableView alloc]init];
    [edittaxTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     edittaxTable.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
    edittaxTable.delegate=self;
    edittaxTable.dataSource=self;
   
   //[TaxView addSubview:edittaxTable];
    
}
-(void)DBbarbutton
{
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [dataresetbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [DBbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
   
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
//db backup view
    
    if (!DbbackUpview)
    DbbackUpview=[[UIView alloc]init];
    DbbackUpview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [DbbackUpview setBackgroundColor:[UIColor whiteColor]];
    [DbbackUpview.layer setBorderWidth: 1.0];
    //[DbbackUpview.layer setCornerRadius:8.0f];
    [DbbackUpview.layer setMasksToBounds:YES];
    [DbbackUpview.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [mainview addSubview:DbbackUpview];
    if (!addDBBackupView)
    addDBBackupView=[[UIView alloc]init];
    addDBBackupView.frame=CGRectMake(10, 10, DbbackUpview.frame.size.width-20, DbbackUpview.frame.size.height-20);
    [addDBBackupView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    addDBBackupView.layer.cornerRadius=8;
    [DbbackUpview addSubview:addDBBackupView];
     CGFloat DBwdth=(addDBBackupView.frame.size.width)/2;
     if (!ServerSynBtn)
    ServerSynBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [ServerSynBtn setTitle:@"Syncronize to server" forState:UIControlStateNormal];
    ServerSynBtn.titleLabel.font=[UIFont systemFontOfSize:20.0f];
    [ServerSynBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
    ServerSynBtn.frame=CGRectMake(DBwdth-140,30,DBwdth-120, 60);
    
    [ServerSynBtn addTarget:self action:@selector(SyncronizeServer) forControlEvents:UIControlEventTouchUpInside];
   
    [ServerSynBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [addDBBackupView addSubview:ServerSynBtn];
    
   /* UploadXlsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    [UploadXlsBtn setTitle:@"Upload product Data" forState:UIControlStateNormal];
    UploadXlsBtn.titleLabel.font=[UIFont systemFontOfSize:20.0f];
    [UploadXlsBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    UploadXlsBtn.frame=CGRectMake(DBwdth-180,90,DBwdth-40, 60);
    
   [UploadXlsBtn addTarget:self action:@selector(UplodexlFiles) forControlEvents:UIControlEventTouchUpInside];
    
    [UploadXlsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [addDBBackupView addSubview:UploadXlsBtn];
    
    ExportDatabaseBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    [ExportDatabaseBtn setTitle:@"Export DataBase" forState:UIControlStateNormal];
    ExportDatabaseBtn.titleLabel.font=[UIFont systemFontOfSize:20.0f];
    [ExportDatabaseBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    ExportDatabaseBtn.frame=CGRectMake(DBwdth-180,150,DBwdth-40, 60);
    
   [ExportDatabaseBtn addTarget:self action:@selector(ExportDataBase) forControlEvents:UIControlEventTouchUpInside];
    
    [ExportDatabaseBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [addDBBackupView addSubview:ExportDatabaseBtn];
    
    ImportDatabaseBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    [ImportDatabaseBtn setTitle:@"Import DataBase" forState:UIControlStateNormal];
    ImportDatabaseBtn.titleLabel.font=[UIFont systemFontOfSize:20.0f];
    [ImportDatabaseBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    ImportDatabaseBtn.frame=CGRectMake(DBwdth-180,210,DBwdth-40, 60);
    
    //[ServerSynBtn addTarget:self action:@selector(ServerSynBackup) forControlEvents:UIControlEventTouchUpInside];
    
    [ImportDatabaseBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [addDBBackupView addSubview:ImportDatabaseBtn];*/
    
}

-(void)SyncronizeServer
{
    SynAlertview=[[UIAlertView alloc]initWithTitle:@"message" message:@"All local data will be deleted.Are you sure that syncronize the server Data" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [SynAlertview show];
}
-(void)Dataresetbarbutton
{
    [CardBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [CompanyBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [CompanyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [taxbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [taxbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DBbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [DBbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [paymentbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [paymentbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Applicationbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Applicationbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [Printerbarbtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [Printerbarbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    UIImage *btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [dataresetbarbtn setBackgroundImage:btnGreyImg forState:UIControlStateNormal];
    [dataresetbarbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
   
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    
//server data base view
    if (!ServerUrlBackView)
    ServerUrlBackView=[[UIView alloc]init];
    ServerUrlBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [ServerUrlBackView setBackgroundColor:[UIColor whiteColor]];
    [ServerUrlBackView.layer setBorderWidth: 1.0];
    [ServerUrlBackView.layer setCornerRadius:8.0f];
    [ServerUrlBackView.layer setMasksToBounds:YES];
    [ServerUrlBackView.layer setBorderColor:[[UIColor blackColor] CGColor]];
     ServerUrlBackView.layer.cornerRadius=8;
    [mainview addSubview:ServerUrlBackView];
    if (!ServerView)
    ServerView=[[UIView alloc]init];
    ServerView.frame=CGRectMake(10, 10, ServerUrlBackView.frame.size.width-20, ServerUrlBackView.frame.size.height-20);
    [ServerView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [ServerUrlBackView addSubview:ServerView];
    
    CGFloat ServerW=ServerView.frame.size.width/3;
    if (!ServerUrllbl)
    ServerUrllbl=[[UILabel alloc]init];
    ServerUrllbl.frame=CGRectMake(ServerW-60,50 ,150, 50);
    [ServerUrllbl setText:@"Server Url"];
    [ServerUrllbl setBackgroundColor:[UIColor clearColor]];
    [ServerUrllbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ServerUrllbl setTextColor:[UIColor whiteColor]];
    [ServerView addSubview:ServerUrllbl];
      if (!ServerTextView)
    ServerTextView = [[UITextField alloc]initWithFrame:CGRectMake(80, 107, ServerW+ServerW+100, 40)];
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(10, 0, 5, 20)];
    ServerTextView.leftView = paddingview;
     ServerTextView.placeholder = @"Enter Server Url";
    ServerTextView.text=[generalDataObject  OriginalbaseURLstr];
    ServerTextView.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ServerTextView.textAlignment= NSTextAlignmentLeft;
    ServerTextView.backgroundColor=[UIColor whiteColor];
   [ServerTextView.layer setBorderWidth:2.0];
    ServerTextView.leftViewMode = UITextFieldViewModeAlways;
      //[username_text setAutocorrectionType:UITextAutocorrectionTypeNo];
    ServerTextView.delegate=self;
     ServerTextView.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [ServerTextView setAutocorrectionType:UITextAutocorrectionTypeDefault];
    [ServerTextView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [ServerView addSubview:ServerTextView];
      if (!SaveServerUrlBtn)
    SaveServerUrlBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    SaveServerUrlBtn.frame=CGRectMake(ServerW-40+ServerW/2,160, 100, 40);
    [SaveServerUrlBtn addTarget:self action:@selector(SaveServerUrl) forControlEvents:UIControlEventTouchUpInside];
    [SaveServerUrlBtn setTitle:@"Save" forState:UIControlStateNormal];
    [SaveServerUrlBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [SaveServerUrlBtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    [ServerView addSubview:SaveServerUrlBtn];
    
    
   
  
}
-(void)SaveServerUrl
{
    if ([ServerTextView.text length]>0)
    {
        NSString *urlstr=ServerTextView.text;
        NSString *lastChar = [urlstr substringFromIndex:[urlstr length] - 1];
        // //NSLog(@"last character %@",lastChar);
        
        // //NSLog(@"url string is %@",urlstr);
        if ([lastChar isEqualToString:@"/"])
        {
            ServerurlStr=[[NSMutableString alloc]initWithString:urlstr];
        }
        else
        {
            ServerurlStr=[[NSMutableString alloc]initWithString:urlstr];
            [ServerurlStr appendFormat:@"%@",@"/"];
        }
        myurlstring=ServerurlStr;
        myurlstring=[NSString stringWithFormat:@"%@%@",ServerurlStr,@"saveinfo.php?"];
        // //NSLog(@"%@",myurlstring);
        NSURL *url = [NSURL URLWithString:myurlstring];
        // //NSLog(@"%@",url);
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
        [request setHTTPMethod:@"HEAD"];
        connection1 = [NSURLConnection connectionWithRequest:request delegate:self];
        [connection1 start];
    }
    
    
    
}
-(void)resetAllclick
{
    if (ProductsBtn.selected){
        [resetAllBtn setSelected:NO];
        
        [SellBtn setSelected:NO];
        [CustomerBtn setSelected:NO];
        [ProductsBtn setSelected:NO];
    }else if(!ProductsBtn.selected){
        [resetAllBtn setSelected:YES];
        
        [SellBtn setSelected:YES];
        [CustomerBtn setSelected:YES];
        [ProductsBtn setSelected:YES];
    }

}

-(void)productsClick
{
    
    if (ProductsBtn.selected)
    {
          [ProductsBtn setSelected:NO];
    }else if(!ProductsBtn.selected){
        [ProductsBtn setSelected:YES];
    }
  
    if (ProductsBtn.selected && SellBtn.selected && CustomerBtn.selected){
        [resetAllBtn setSelected:YES];
        
    }else{
        [resetAllBtn setSelected:NO];
    }
    
}
-(void)sellClick
{
    if (SellBtn.selected){
        [SellBtn setSelected:NO];
    }else if(!SellBtn.selected)
    {
        [SellBtn setSelected:YES];
    }
    if (ProductsBtn.selected && SellBtn.selected && CustomerBtn.selected){
        [resetAllBtn setSelected:YES];
        
    }else{
        [resetAllBtn setSelected:NO];
    }
}
-(void)CustomerClick
{
    if (CustomerBtn.selected){
        [CustomerBtn setSelected:NO];
    }else if(!CustomerBtn.selected){
        [CustomerBtn setSelected:YES];
    }
    if (ProductsBtn.selected && SellBtn.selected && CustomerBtn.selected){
        [resetAllBtn setSelected:YES];
        
    }else{
        [resetAllBtn setSelected:NO];
    }
}

-(void)ResetdataClick
{
    resetdataAlert=[[UIAlertView alloc]initWithTitle:@"Reset" message:@"Are you sure you want to Reset The Data" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [resetdataAlert show];
    
}
-(void)addtaxbutton
{
     [editTaxButton setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
     [addtaxBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [editTaxButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
      [addtaxBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [edittaxTable removeFromSuperview];
    [TaxView addSubview:AddTaxView];
}
-(void)edittaxbutton
{
    [addtaxBtn setBackgroundColor:[UIColor whiteColor]];
    [addtaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [editTaxButton setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
     //addtaxBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [addtaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
      [editTaxButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [addtaxBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [AddTaxView removeFromSuperview];
    NSString *querySQL2 = [NSString stringWithFormat: @"SELECT name,tax_value FROM taxes"];
    taxDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxDataArray];
    
    [TaxView addSubview:edittaxTable];
}
-(void)addpaymentClick
{
    [editpaymentBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [addpaymentBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
      [addpaymentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [editpaymentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [PaymentTable removeFromSuperview];
    [paymentview addSubview:AddpaymentView];
}
-(void)editpaymenClick
{
    
    [addpaymentBtn setBackgroundColor:[UIColor whiteColor]];
    [addpaymentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [editpaymentBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    //addtaxBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [addpaymentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [editpaymentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [addpaymentBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [AddpaymentView removeFromSuperview];
    NSString *querySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
    paymentDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:paymentDataArray];
    [paymentview addSubview:PaymentTable];
    
}
-(void)SaveTax
{
   
   
    NSString *insertSQL =@"insert into taxes (unique_id,created_timestamp,modified_timestamp,name,tax_value) values(?,?,?,?,?)";
    
    NSMutableArray *taxArray=[[NSMutableArray alloc]initWithObjects:[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],nameTextfield.text,RateTextfield.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:taxArray];
    
    NSString *querySQL2 = [NSString stringWithFormat: @"SELECT name,tax_value FROM taxes"];
    taxDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxDataArray];
    
    [edittaxTable reloadData];
   
}
-(void)SavepaymentClick
{
  
   NSString *insertSQL = @"insert into payments (unique_id,payment_name, payment_value) VALUES (?,?,?)";
    
    NSMutableArray *paymentsArray=[[NSMutableArray alloc]initWithObjects:[generalDataObject  genRandStringLength:20],paymentnameField.text,@"yes", nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:paymentsArray];
    
    NSString *querySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
     paymentDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:paymentDataArray];
    [PaymentTable reloadData];
}
-(void)Canceltax
{
    [RateTextfield setText:@""];
    [nameTextfield setText:@""];
}
-(void)CancelpaymentClick
{
    [paymentnameField setText:@""];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    // This will create a "invisible" footer
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
    
    // If you are not using ARC:
    // return [[UIView new] autorelease];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView== edittaxTable){
        return [taxDataArray count]+1;

    }else if (tableView== PaymentTable){
        return [paymentDataArray count]+1;
        
    }else if (tableView== aligndataTable){
        return [aligndataArray count];
        
    }else if (tableView== fontsTable){
        return [fontsizesArray count];
        
    }else if (tableView== printermethodsTable){
        return [printmethodsArray count];
        
    }else if (tableView==DepartmentsTable){
        return [DepartmentsArray count];
    }else if (tableView==ItemsTable){
        return [ItemsArray count];
    }else if (tableView == alignLineSpaTV){
        return [alignLineSpacArray count];
    }else if (tableView== languageTV){
        return [langArray count];
        
    }else if (tableView == sizeWidthTV){
        return [sizeWidthArray count];
        
    }else if (tableView == sizeHeightTV){
        return [sizeheightArray count];
        
    }else if (tableView == printerNameTV){
        return [printerNameArray count];
        
    }else if (tableView == fontTableView){
        return [fontArray count];
    }else if (tableView==editPrinterTable){
        return [PrinterIdsArray count]+1;
    }else if (tableView == EditalignLineSpaTV){
        return [alignLineSpacArray count];
    }else if (tableView== EditlanguageTV){
        return [langArray count];
        
    }else if (tableView == EditsizeWidthTV){
        return [sizeWidthArray count];
        
    }else if (tableView == EditsizeHeightTV){
        return [sizeheightArray count];
        
    }else if (tableView == EditprinterNameTV){
        return [printerNameArray count];
        
    }else if (tableView == EditPrinterTypesTable){
        return [PrintertypesArray count];
    }else if (tableView == EditfontTableView){
        return [fontArray count];
    }else if (tableView==PrinterTypesTable){
        return [PrintertypesArray count];
    }else if (tableView==paymentTableView){
        return [paymentArray count];
    }
    return YES;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
   if (tableView == editPrinterTable){
        
        PrinterCell  *cell = (PrinterCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"PrinterCell" owner:self options:nil];
            cell = printerCell;
        }
        if (indexPath.row==0){
            cell.printerID_TextView.text=@"PrinterID";
            cell.ipAddress_TextView.text=@"IpAddress/PortName";
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.printerID_TextView.textColor=[UIColor blackColor];
            cell.ipAddress_TextView.textColor=[UIColor blackColor];
            cell.edit_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            
        }else{
            cell.printerID_TextView.text=[PrinterIdsArray objectAtIndex:indexPath.row-1];
            cell.ipAddress_TextView.text=[IpAddsArray objectAtIndex:indexPath.row-1];
            
            cell.printerID_TextView.textColor=[UIColor whiteColor];
            cell.ipAddress_TextView.textColor=[UIColor whiteColor];
            cell.edit_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            cell.edit_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        return cell;
        
   }else if (tableView == edittaxTable){
       
       TaxesCell  *cell = (TaxesCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
       
       if(!cell) {
           [[NSBundle mainBundle] loadNibNamed:@"TaxesCell" owner:self options:nil];
           cell = taxesCell;
       }

       if (indexPath.row==0){
           cell.name_TextView.text=@"TaxName";
           cell.rate_TextView.text=@"Rate";
           cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
           
           cell.name_TextView.textColor=[UIColor blackColor];
           cell.rate_TextView.textColor=[UIColor blackColor];
           cell.edit_Button.hidden=YES;
           cell.delete_Button.hidden=YES;
           
       }else{
           
           NSDictionary *dict=[taxDataArray objectAtIndex:indexPath.row-1];
           cell.name_TextView.text=[dict objectForKey:@"name"];
           cell.rate_TextView.text=[dict objectForKey:@"tax_value"];
           
           cell.name_TextView.textColor=[UIColor whiteColor];
           cell.rate_TextView.textColor=[UIColor whiteColor];
           cell.edit_Button.hidden=NO;
           cell.delete_Button.hidden=NO;
           cell.edit_Button.tag=indexPath.row;
           cell.delete_Button.tag=indexPath.row;
           if (indexPath.row%2==0){
               
               cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
           }else
           {
               cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
               
           }
           
       }
     
       return cell;
       
   }else if (tableView == PaymentTable){
       
       PaymentCell  *cell = (PaymentCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
       
       if(!cell) {
           [[NSBundle mainBundle] loadNibNamed:@"PaymentCell" owner:self options:nil];
           cell = paymentCell;
       }
       
       
       if (indexPath.row==0){
           cell.name_TextView.text=@"PaymentName";
           cell.rate_TextView.text=@"Value";
           cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
           
           cell.name_TextView.textColor=[UIColor blackColor];
           cell.rate_TextView.textColor=[UIColor blackColor];
           cell.edit_Button.hidden=YES;
           cell.delete_Button.hidden=YES;
           
       }else{
          
           NSDictionary *dict=[paymentDataArray objectAtIndex:indexPath.row-1];

           cell.name_TextView.text=[dict objectForKey:@"payment_name"];
           cell.rate_TextView.text=[dict objectForKey:@"payment_value"];
           
           cell.name_TextView.textColor=[UIColor whiteColor];
           cell.rate_TextView.textColor=[UIColor whiteColor];
           cell.edit_Button.hidden=NO;
           cell.delete_Button.hidden=NO;
           cell.edit_Button.tag=indexPath.row;
           cell.delete_Button.tag=indexPath.row;
           if (indexPath.row%2==0){
               
               cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
           }else
           {
               cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
               
           }
           
       }
      
       return cell;
       
   }else{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   
       if(!cell) {
           cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
       }
    
    if (tableView == paymentTableView)
    {
        cell.textLabel.text = [paymentArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        
    }else if (tableView == PrinterTypesTable){
        cell.textLabel.text=[PrintertypesArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
    }else if (tableView == fontTableView){
        cell.textLabel.text=[fontArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
    }else if (tableView == alignLineSpaTV){
        cell.textLabel.text = [alignLineSpacArray objectAtIndex:indexPath.row];
        
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
    }else if (tableView == languageTV ){
        cell.textLabel.text= [langArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        
    }else if (tableView == sizeWidthTV){
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        cell.textLabel.text= [sizeWidthArray objectAtIndex:indexPath.row];
    }else if (tableView == sizeHeightTV){
        cell.textLabel.text=[sizeheightArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
        
    }else if (tableView == printerNameTV){
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
        cell.textLabel.text=[printerNameArray objectAtIndex:indexPath.row];
    }else if (tableView == EditfontTableView){
        cell.textLabel.text=[fontArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
    }else if (tableView == EditalignLineSpaTV){
        cell.textLabel.text = [alignLineSpacArray objectAtIndex:indexPath.row];
        
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
    }else if (tableView == EditlanguageTV ){
        cell.textLabel.text= [langArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        
    }else if (tableView == EditsizeWidthTV){
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        cell.textLabel.text= [sizeWidthArray objectAtIndex:indexPath.row];
    }else if (tableView == EditsizeHeightTV){
        cell.textLabel.text=[sizeheightArray objectAtIndex:indexPath.row];
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
        
    }else if (tableView == EditprinterNameTV){
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
        cell.textLabel.text=[printerNameArray objectAtIndex:indexPath.row];
    }else if (tableView == EditPrinterTypesTable){
        cell.textLabel.textAlignment= NSTextAlignmentCenter;
        cell.textLabel.text=[PrintertypesArray objectAtIndex:indexPath.row];
    }
    if ([DepartmentsArray  count]>0)
    {
        if (tableView==DepartmentsTable)
        {
            cell.textLabel.text=[DepartmentsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor blackColor];
            for (int i=0; i<[DepartmentsArray count]; i++)
            {
                if (indexPath.row==i)
                {
    
                   DeptCheckBox=[UIButton buttonWithType:UIButtonTypeCustom];
                    if (isLandScope)
                    {
                         [DeptCheckBox setFrame:CGRectMake(320, 10, 25, 25)];
                    }
                    else
                    {
                        [DeptCheckBox setFrame:CGRectMake(240, 10, 25, 25)];
                    }
            //[editBtn setTitle:@"edit" forState:UIControlStateNormal];
            [DeptCheckBox setImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
            [DeptCheckBox setImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
           
            [DeptCheckBox addTarget:self action:@selector(DepartmentCheckBox:) forControlEvents:UIControlEventTouchUpInside];
            DeptCheckBox.tag=indexPath.row;
           
            
                NSString *check=[ChecksArray objectAtIndex:i];
                if ([check isEqualToString:@"true"])
                {
                     DeptCheckBox.selected=YES;
                }
                else if ([check isEqualToString:@"false"])
                {
                     DeptCheckBox.selected=NO;
                }
                [cell.contentView addSubview:DeptCheckBox];
                }
            }
            
            
        }
    }
    if ([ItemsArray  count]>0)
    {
        if (tableView==ItemsTable)
        {
            cell.textLabel.text=[ItemsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor blackColor];
            ItemCheckBox=[UIButton buttonWithType:UIButtonTypeCustom];
            for (int i=0; i<[ItemsArray count]; i++)
            {
    
                if (indexPath.row==i)
                {
                    
                    if (isLandScope)
                    {
                         [ItemCheckBox setFrame:CGRectMake(320, 10, 25, 25)];
                    }
                    else
                    {
                          [ItemCheckBox setFrame:CGRectMake(240, 10, 25, 25)];
                    }
            //[editBtn setTitle:@"edit" forState:UIControlStateNormal];
            [ItemCheckBox setImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
            [ItemCheckBox setImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];

              [ItemCheckBox addTarget:self action:@selector(ItemCheckBox:) forControlEvents:UIControlEventTouchUpInside];
               ItemCheckBox.tag=indexPath.row;
           
                    NSString *check=[ItemChecksArray objectAtIndex:i];
                    if ([check isEqualToString:@"true"])
                    {
                        ItemCheckBox.selected=YES;
                    }
                    else if ([check isEqualToString:@"false"])
                    {
                        ItemCheckBox.selected=NO;
                    }
                    [cell.contentView addSubview:ItemCheckBox];
                }
            }
            
            
        }
    }
    return cell;
   }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView == paymentTableView){
        paymentTableView.hidden=YES;
        paymentStr= [paymentArray objectAtIndex:indexPath.row];
        [paymentButton setTitle:paymentStr forState:UIControlStateNormal];
        [self savePayment];
        if ([paymentStr isEqualToString:@"Express Manual"]){
            //[PrimaryField setHidden:YES];
            
            primaryurllbl.hidden=YES;
            PrimaryField.hidden=YES;
            SecondaryField.hidden=YES;
            Securllbl.hidden=YES;
            MerchantField.hidden=YES;
            merchantNolbl.hidden=YES;
            terminalNolbl.hidden=YES;
            TerminalField.hidden=YES;
            ProcessBtn.hidden=YES;
            Processdebittextlbl.hidden=YES;
            RequireBtn.hidden=YES;
            requiretextlbl.hidden=YES;
            saveCardDataBtn.hidden=YES;
            timeoutlbl.hidden=YES;
            timeoutTextField.hidden=YES;
            [paymentTableView reloadData];
            
            
        }else if ([paymentStr isEqualToString:@"First Data"]){
            primaryurllbl.hidden=NO;
            PrimaryField.hidden=NO;
            SecondaryField.hidden=NO;
            Securllbl.hidden=NO;
            MerchantField.hidden=NO;
            merchantNolbl.hidden=NO;
            terminalNolbl.hidden=NO;
            TerminalField.hidden=NO;
            ProcessBtn.hidden=NO;
            Processdebittextlbl.hidden=NO;
            RequireBtn.hidden=NO;
            requiretextlbl.hidden=NO;
            saveCardDataBtn.hidden=NO;
            timeoutlbl.hidden=YES;
            timeoutTextField.hidden=YES;
            terminalNolbl.text=@"Terminal Number";
            TerminalField.placeholder=@"Enter TID";
            [paymentTableView reloadData];
        }
        else if ([paymentStr isEqualToString:@"Mercury"]){
            primaryurllbl.hidden=NO;
            PrimaryField.hidden=NO;
            SecondaryField.hidden=NO;
            Securllbl.hidden=NO;
            MerchantField.hidden=NO;
            merchantNolbl.hidden=NO;
            terminalNolbl.hidden=NO;
            TerminalField.hidden=NO;
            ProcessBtn.hidden=YES;
            Processdebittextlbl.hidden=YES;
            RequireBtn.hidden=YES;
            timeoutlbl.hidden=NO;
            timeoutTextField.hidden=NO;
            requiretextlbl.hidden=YES;
            saveCardDataBtn.hidden=NO;
            terminalNolbl.text=@"Password";
            TerminalField.placeholder=@"Enter password";
            [paymentTableView reloadData];
        }
        
    }else if (tableView == PrinterTypesTable){
        PrinterTypesTable.hidden=YES;
       
        NSString * selectAlignStr= [PrintertypesArray objectAtIndex:indexPath.row];
        [PrinterTypeBtn setTitle:selectAlignStr forState:UIControlStateNormal];

        if ([selectAlignStr isEqualToString:@"STAR"])
        {
            printerNameArray=[NSArray arrayWithObjects:@"TSP650II WebPRNT",@"TSP650II BTi",@"TSP650II",@"TSP100ECO",@"TSP100",@"TSP100GT",@"TSP650 Resto",@"TSP654SK",@"  TSP700II",@"TSP800II",@"TSP800IIRx",@"FVP-10",@"TSP1000", nil];
            
            [printerNameTV reloadData];
           
            wifiLabel.hidden=NO;
          
            btLabel.hidden=NO;
            wifi_Switch.hidden=NO;
            
        }else if ([selectAlignStr isEqualToString:@"EPSON"]){
            printerNameArray=[NSArray arrayWithObjects:@"TM-T88V",@"TM-T70",@"TM-U220",@"TM-P60",@"TM-P60II",@"TM-T20",@"TM-T82",@"TM-T81II",@"TM-T82II", @"TM-T70II",Nil];
            
            [printerNameTV reloadData];
         
            wifiLabel.hidden=YES;
           
            btLabel.hidden=YES;
            wifi_Switch.hidden=YES;
            
        }
        
    }else if (tableView == alignLineSpaTV){
        alignLineSpaTV.hidden=YES;
        languageButton.hidden=NO;
        NSString * selectAlignStr= [alignLineSpacArray objectAtIndex:indexPath.row];
        [alignLineSpaButton setTitle:selectAlignStr forState:UIControlStateNormal];
    }else if (tableView == fontTableView){
        fontTableView.hidden=YES;
        alignLineSpaButton.hidden=NO;
        NSString * selectAlignStr= [fontArray objectAtIndex:indexPath.row];
        [fontButton setTitle:selectAlignStr forState:UIControlStateNormal];
    }else if (tableView == languageTV){
        languageTV.hidden=YES;
        sizeButton.hidden=NO;
        NSString * selectLangStr = [langArray objectAtIndex:indexPath.row];
        [languageButton setTitle:selectLangStr forState:UIControlStateNormal];
        
    }else if (tableView == sizeWidthTV){
        sizeWidthTV.hidden=YES;
        NSString * selectSizeStr = [sizeWidthArray objectAtIndex:indexPath.row];
        [sizeButton setTitle:selectSizeStr forState:UIControlStateNormal];
        
    }else if (tableView == sizeHeightTV){
        sizeHeightTV.hidden=YES;
        NSString * selectSizeHeiStr= [sizeheightArray objectAtIndex:indexPath.row];
        [widthButton setTitle:selectSizeHeiStr forState:UIControlStateNormal];
    }else if (tableView == printerNameTV){
        printerNameTV.hidden=YES;
        NSString * selectPrintStr= [printerNameArray objectAtIndex:indexPath.row];
        [printerNameButton setTitle:selectPrintStr forState:UIControlStateNormal];
    }else if (tableView == EditalignLineSpaTV){
        EditalignLineSpaTV.hidden=YES;
        EditlanguageButton.hidden=NO;
        NSString * selectAlignStr= [alignLineSpacArray objectAtIndex:indexPath.row];
        [EditalignLineSpaButton setTitle:selectAlignStr forState:UIControlStateNormal];
    }else if (tableView == EditfontTableView){
        EditfontTableView.hidden=YES;
        EditalignLineSpaButton.hidden=NO;
        NSString * selectAlignStr= [fontArray objectAtIndex:indexPath.row];
        [EditfontButton setTitle:selectAlignStr forState:UIControlStateNormal];
    }else if (tableView == EditlanguageTV){
        EditlanguageTV.hidden=YES;
        sizeButton.hidden=NO;
        NSString * selectLangStr = [langArray objectAtIndex:indexPath.row];
        [EditlanguageButton setTitle:selectLangStr forState:UIControlStateNormal];
        
    }else if (tableView == EditsizeWidthTV){
        EditsizeWidthTV.hidden=YES;
        NSString * selectSizeStr = [sizeWidthArray objectAtIndex:indexPath.row];
        [EditsizeButton setTitle:selectSizeStr forState:UIControlStateNormal];
        
    }else if (tableView == EditsizeHeightTV){
        EditsizeHeightTV.hidden=YES;
        NSString * selectSizeHeiStr= [sizeheightArray objectAtIndex:indexPath.row];
        [EditwidthButton setTitle:selectSizeHeiStr forState:UIControlStateNormal];
    }else if (tableView == EditprinterNameTV){
        EditprinterNameTV.hidden=YES;
        NSString * selectPrintStr= [printerNameArray objectAtIndex:indexPath.row];
        [EditprinterNameButton setTitle:selectPrintStr forState:UIControlStateNormal];
        
        
    }else  if (tableView == EditPrinterTypesTable){
        EditPrinterTypesTable.hidden=YES;
        NSString * selectPrintStr= [PrintertypesArray objectAtIndex:indexPath.row];
        [EditPrinterTypeBtn setTitle:selectPrintStr forState:UIControlStateNormal];
        
        if ([selectPrintStr isEqualToString:@"STAR"])
        {
            printerNameArray=[NSArray arrayWithObjects:@"TSP650II WebPRNT",@"TSP650II BTi",@"TSP650II",@"TSP100ECO",@"TSP100",@"TSP100GT",@"TSP650 Resto",@"TSP654SK",@"  TSP700II",@"TSP800II",@" TSP800IIRx",@"FVP-10",@"TSP1000", nil];
            
            [EditprinterNameTV reloadData];
            editbtLabel.hidden=NO;
            editwifi_Switch.hidden=NO;
            editwifiLabel.hidden=NO;
            
        }else if ([selectPrintStr isEqualToString:@"EPSON"]){
            printerNameArray=[NSArray arrayWithObjects:@"TM-T88V",@"TM-T70",@"TM-U220",@"TM-P60",@"TM-P60II",@"TM-T20",@"TM-T82",@"TM-T81II",@"TM-T82II", @"TM-T70II",Nil];
            
            [EditprinterNameTV reloadData];
            
            editbtLabel.hidden=YES;
            editwifi_Switch.hidden=YES;
            editwifiLabel.hidden=YES;
            
        }
        
        
    }else if (tableView==DepartmentsTable){
        
        ItemsArray=[[NSMutableArray alloc]init];
        ItemChecksArray=[[NSMutableArray alloc]init];
        NSString *str=[DepartmentsArray objectAtIndex:indexPath.row];
      NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_department,inventary_item_name,check_value FROM inventorytable"];
        NSMutableArray *productArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productArray];
        
        for (NSDictionary *myDict in productArray)
        {
            NSString *valuesstr=[myDict objectForKey:@"inventary_department"];
            if ([valuesstr isEqualToString:str]){
                NSString *valuesstr=[myDict objectForKey:@"inventary_item_name"];
                
                [ItemChecksArray addObject:[myDict objectForKey:@"check_value"]];
                [ItemsArray addObject:valuesstr];
            }
            valuesstr=nil;
        }
        ItemsTable.hidden=NO;
        [ItemsTable reloadData];
    }
    
}
-(void)savePayment
{
    
     NSString *querySQL = [NSString stringWithFormat: @"SELECT paymentprocessorname FROM paymentprocessorpreferencess"];
    NSMutableArray *paytypesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:paytypesArray];
    
    if ([paytypesArray count]>0)
    {
        NSString *updateSQL3 = @"DELETE FROM paymentprocessorpreferencess";
       
        NSMutableArray *deleteArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:deleteArray];
        
        NSString * paymentSave=@"insert into paymentprocessorpreferencess (paymentprocessorname,paymentprocessorselectvalue) values (?,?)";
        
        NSMutableArray *payinsertArray=[[NSMutableArray alloc]initWithObjects:paymentStr,paymentStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:paymentSave withArguments:payinsertArray];
        
        
         paymentSave=nil,updateSQL3=nil;
        
    }else{
        
        NSString * paymentSave=@"insert into paymentprocessorpreferencess (paymentprocessorname,paymentprocessorselectvalue) values (?,?)";
        
        NSMutableArray *payinsertArray=[[NSMutableArray alloc]initWithObjects:paymentStr,paymentStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:paymentSave withArguments:payinsertArray];
        paymentSave=nil;
    }
    
}
- (IBAction)printer_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    NSInteger  selectedrow=but.tag-1;
    if (!EditPrinterPopUpView)
    EditPrinterPopUpView=[[UIView alloc]init];
    if (isLandScope){
        EditPrinterPopUpView.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditPrinterPopUpView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditPrinterPopUpView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditPrinterPopUpView];
    if (!EditPrinterView)
    EditPrinterView=[[UIScrollView alloc]init];
    EditPrinterView.frame=CGRectMake(50,30, EditPrinterPopUpView.frame.size.width-100, EditPrinterPopUpView.frame.size.height-60);
    EditPrinterView.contentSize=CGSizeMake(EditPrinterPopUpView.frame.size.width-100,EditPrinterPopUpView.frame.size.height+500);
    [EditPrinterView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [EditPrinterView.layer setBorderWidth:2.0];
    [EditPrinterView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    EditPrinterView.layer.cornerRadius=8;
    [EditPrinterPopUpView addSubview:EditPrinterView];
    
    SearchPrinterStr=[searchPrinterArray objectAtIndex:selectedrow];
    PrinterName=[printernamesArray objectAtIndex:selectedrow];
    
    NSString *printChar=[printcharArray objectAtIndex:selectedrow];
    NSString *font=[FontsArray objectAtIndex:selectedrow];
    NSString *align=[AlignsArray objectAtIndex:selectedrow];
    NSString *language=[languagesArray objectAtIndex:selectedrow];
    NSString *width=[WidthsArray objectAtIndex:selectedrow];
    NSString *height=[HeightsArray objectAtIndex:selectedrow];
    
    Bold=[boldsArray objectAtIndex:selectedrow];
    Underline=[UnderlinesArray objectAtIndex:selectedrow];
    
    NSString *xposition =[XpossArray objectAtIndex:selectedrow];
    NSString *spacing=[spacingsArray objectAtIndex:selectedrow];
    NSString *printername=[printernamesArray objectAtIndex:selectedrow];
    NSString *Ipadd=[IpAddsArray objectAtIndex:selectedrow];
    NSString *printerid=[PrinterIdsArray objectAtIndex:selectedrow];
    NSString *unit=[unitsArray objectAtIndex:selectedrow];
    NSString *Dbprintertype=[DbPrinterTypesArray objectAtIndex:selectedrow];
    
    
    if ([Dbprintertype isEqualToString:@"STAR"]){ if (!printerNameArray)
        printerNameArray=[NSArray arrayWithObjects:@"TSP650II WebPRNT",@"TSP650II BTi",@"TSP650II",@"TSP100ECO",@"TSP100",@"TSP100GT",@"TSP650 Resto",@"TSP654SK",@"  TSP700II",@"TSP800II",@" TSP800IIRx",@"FVP-10",@"TSP1000", nil];
        
        [EditprinterNameTV reloadData];
        
    }else if ([Dbprintertype isEqualToString:@"EPSON"]){
        if (!printerNameArray)
        printerNameArray=[NSArray arrayWithObjects:@"TM-T88V",@"TM-T70",@"TM-U220",@"TM-P60",@"TM-P60II",@"TM-T20",@"TM-T82",@"TM-T81II",@"TM-T82II", @"TM-T70II",Nil];
        
        [EditprinterNameTV reloadData];
        
    }
    
    CGFloat EditPrinterw=EditPrinterView.frame.size.width/3;
      if (!EditprintCharLabel)
    EditprintCharLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 20, EditPrinterw, 30)];
    EditprintCharLabel.text= @"Printer Charecter";
    EditprintCharLabel.backgroundColor=[UIColor clearColor];
    EditprintCharLabel.textColor=[UIColor whiteColor];
    EditprintCharLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditprintCharLabel];
      if (!EditprinterCharTF)
    EditprinterCharTF = [[UITextView alloc]initWithFrame:CGRectMake(EditPrinterw, 55, EditPrinterw, 30)];
    EditprinterCharTF.text=printChar;
    //printerCharTF.borderStyle = UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditprinterCharTF];
    if (!EditfontLabel)
    EditfontLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 85, EditPrinterw, 30)];
    EditfontLabel.text= @"Font";
    EditfontLabel.backgroundColor=[UIColor clearColor];
    EditfontLabel.textColor=[UIColor whiteColor];
    EditfontLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditfontLabel];
     if (!EditfontButton)
    EditfontButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditfontButton.frame=CGRectMake(EditPrinterw, 115, 200, 30);
    [EditfontButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    EditfontButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditfontButton setTitle:font forState:UIControlStateNormal];
    [EditfontButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditfontButton addTarget:self action:@selector(EditFontsizesetClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditfontButton];
     if (!EditalignLineSpaLabel)
    EditalignLineSpaLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 145, EditPrinterw, 30)];
    EditalignLineSpaLabel.text= @"Align";
    EditalignLineSpaLabel.backgroundColor=[UIColor clearColor];
    EditalignLineSpaLabel.textColor=[UIColor whiteColor];
    EditalignLineSpaLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditalignLineSpaLabel];
     if (!EditalignLineSpaButton)
    EditalignLineSpaButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditalignLineSpaButton.frame=CGRectMake(EditPrinterw, 175, 200, 30);
    [EditalignLineSpaButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditalignLineSpaButton setTitle:align forState:UIControlStateNormal];
    EditalignLineSpaButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditalignLineSpaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditalignLineSpaButton addTarget:self action:@selector(EditalignLineSpaceClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditalignLineSpaButton];
    if (!EditlangLabel)
    EditlangLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 205, EditPrinterw, 30)];
    EditlangLabel.text=@"Language";
    EditlangLabel.backgroundColor=[UIColor clearColor];
    EditlangLabel.textColor=[UIColor whiteColor];
    EditlangLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditlangLabel];
    if (!EditlanguageButton)
    EditlanguageButton  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditlanguageButton.frame=CGRectMake(EditPrinterw, 235, 200, 30);
    [EditlanguageButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditlanguageButton setTitle:language forState:UIControlStateNormal];
    EditlanguageButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditlanguageButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditlanguageButton addTarget:self action:@selector(EditlanguageButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditlanguageButton];
      if (!EditsizeLabel)
    EditsizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 265, EditPrinterw, 30)];
    EditsizeLabel.text=@"Size(width,Height)";
    EditsizeLabel.backgroundColor=[UIColor clearColor];
    EditsizeLabel.textColor=[UIColor whiteColor];
    EditsizeLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditsizeLabel];
     if (!EditsizeButton)
    EditsizeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditsizeButton.frame=CGRectMake(EditPrinterw, 295, EditPrinterw/2, 30);
    [EditsizeButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditsizeButton setTitle:width forState:UIControlStateNormal];
    EditsizeButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditsizeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditsizeButton addTarget:self action:@selector(EditsizeClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditsizeButton];
    if (!EditwidthButton)
    EditwidthButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditwidthButton.frame=CGRectMake(EditPrinterw+EditsizeButton.frame.size.width+5, 295, EditPrinterw/2, 30);
    [EditwidthButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditwidthButton setTitle:height forState:UIControlStateNormal];
    EditwidthButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditwidthButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditwidthButton addTarget:self action:@selector(EditwidthClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditwidthButton];
    
     if (!EditstyleLabel)
    EditstyleLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 325, EditPrinterw/2, 30)];
    EditstyleLabel.text = @"Style";
    EditstyleLabel.backgroundColor=[UIColor clearColor];
    EditstyleLabel.textColor=[UIColor whiteColor];
    EditstyleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditstyleLabel];
    if (!EditboldLabel)
    EditboldLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw+10, 355, EditPrinterw/2, 30)];
    EditboldLabel.text = @"Bold";
    EditboldLabel.backgroundColor=[UIColor clearColor];
    EditboldLabel.textColor=[UIColor whiteColor];
    EditboldLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditboldLabel];
     if (!EditboldSwitch)
    EditboldSwitch=[[UISwitch alloc]initWithFrame:CGRectMake(EditPrinterw+10+EditboldLabel.frame.size.width, 355, 100, 30)];
    [EditboldSwitch addTarget:self action:@selector(EditboldSwitchClick:) forControlEvents:UIControlEventValueChanged];
    [EditPrinterView addSubview:EditboldSwitch];
    if ([Bold isEqualToString:@"1"])
    {
        [EditboldSwitch setOn:TRUE animated:YES];
    }else{
        [EditboldSwitch setOn:FALSE animated:YES];
    }
    if (!EditunderLineLabel)
    EditunderLineLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw+10, 385, EditPrinterw, 30)];
    EditunderLineLabel.text=@"UnderLine";
    EditunderLineLabel.backgroundColor=[UIColor clearColor];
    EditunderLineLabel.textColor=[UIColor whiteColor];
    EditunderLineLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditunderLineLabel];
    if (!EditunderlineSwitch)
    EditunderlineSwitch= [[UISwitch alloc]initWithFrame:CGRectMake(EditPrinterw+10+boldLabel.frame.size.width, 390, 100, 30)];
    [EditunderlineSwitch addTarget:self action:@selector(EditunderlineSwitchClick:) forControlEvents:UIControlEventValueChanged];
    [EditPrinterView addSubview:EditunderlineSwitch];
    
    if ([Underline isEqualToString:@"1"])
    {
        [EditunderlineSwitch setOn:TRUE animated:YES];
     
    }else{
        [EditunderlineSwitch setOn:FALSE animated:YES];
    }
    
    if (!EditxPositionLabel)
    EditxPositionLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 415, EditPrinterw, 30)];
    EditxPositionLabel.text= @"X Position";
    EditxPositionLabel.backgroundColor=[UIColor clearColor];
    EditxPositionLabel.textColor=[UIColor whiteColor];
    EditxPositionLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditxPositionLabel];
    if (!EditxPositionTF)
    EditxPositionTF = [[UITextField alloc]initWithFrame:CGRectMake(EditPrinterw, 445, EditPrinterw, 30)];
    EditxPositionTF.text=xposition;
    EditxPositionTF.borderStyle=UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditxPositionTF];
    if (!EditfeedUnitLabel)
    EditfeedUnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 475, EditPrinterw, 30)];
    EditfeedUnitLabel.text= @"Feed Unit";
    EditfeedUnitLabel.backgroundColor=[UIColor clearColor];
    EditfeedUnitLabel.textColor=[UIColor whiteColor];
    EditfeedUnitLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditfeedUnitLabel];
     if (!EditfeedUnitTF)
    EditfeedUnitTF = [[UITextField alloc]initWithFrame:CGRectMake(EditPrinterw, 505, EditPrinterw, 30)];
    EditfeedUnitTF.text=unit;
    EditfeedUnitTF.borderStyle=UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditfeedUnitTF];
    if (!EditPrintertypelabel)
    EditPrintertypelabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 535, EditPrinterw, 30)];
    EditPrintertypelabel.text=@"Printer Type";
    EditPrintertypelabel.backgroundColor=[UIColor clearColor];
    EditPrintertypelabel.textColor=[UIColor whiteColor];
    EditPrintertypelabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditPrintertypelabel];
     if (!EditPrinterTypeBtn)
    EditPrinterTypeBtn  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditPrinterTypeBtn.frame=CGRectMake(EditPrinterw, 565, 200, 30);
    [EditPrinterTypeBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditPrinterTypeBtn setTitle:Dbprintertype forState:UIControlStateNormal];
    EditPrinterTypeBtn.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditPrinterTypeBtn addTarget:self action:@selector(EditprinterTypeClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditPrinterTypeBtn];
    if (!EditPrinterNameLabel)
    EditPrinterNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 595, EditPrinterw, 30)];
    EditPrinterNameLabel.text=@"Printer Name";
    EditPrinterNameLabel.backgroundColor=[UIColor clearColor];
    EditPrinterNameLabel.textColor=[UIColor whiteColor];
    EditPrinterNameLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditPrinterNameLabel];
    if (!EditprinterNameButton)
    EditprinterNameButton  = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditprinterNameButton.frame=CGRectMake(EditPrinterw, 625, 200, 30);
    [EditprinterNameButton setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [EditprinterNameButton setTitle:printername forState:UIControlStateNormal];
    EditprinterNameButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditprinterNameButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditprinterNameButton addTarget:self action:@selector(EditprinterNameClick) forControlEvents:UIControlEventTouchUpInside];
    [EditPrinterView addSubview:EditprinterNameButton];
    if (!editwifiLabel)
    editwifiLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw+EditPrinterw+5, 565, 50, 30)];
    editwifiLabel.text=@"wifi";
    editwifiLabel.backgroundColor=[UIColor clearColor];
    editwifiLabel.textColor=[UIColor whiteColor];
    editwifiLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:editwifiLabel];
    if (!editwifi_Switch)
    editwifi_Switch=[[UISwitch alloc]initWithFrame:CGRectMake(EditPrinterw+EditPrinterw+55, 565, 100, 30)];
    [editwifi_Switch addTarget:self action:@selector(wifiSwitchClick:) forControlEvents:UIControlEventValueChanged];
   
    [EditPrinterView addSubview:editwifi_Switch];
     if (!editbtLabel)
    editbtLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw+EditPrinterw+125, 565, 100, 30)];
    editbtLabel.text=@"Bluetooth";
    editbtLabel.backgroundColor=[UIColor clearColor];
    editbtLabel.textColor=[UIColor whiteColor];
    editbtLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:editbtLabel];
    
    if ([SearchPrinterStr isEqualToString:@"BT"])
    {
        [editwifi_Switch setOn:TRUE animated:YES];
        
    }else{
        [editwifi_Switch setOn:FALSE animated:YES];
    }
    if ([Dbprintertype isEqualToString:@"STAR"]){
        editwifiLabel.hidden=NO;
        editwifi_Switch.hidden=NO;
        editbtLabel.hidden=NO;
    }else{
        editwifiLabel.hidden=YES;
        editwifi_Switch.hidden=YES;
        editbtLabel.hidden=YES;
    }
     if (!EditprinterIDLabel)
    EditprinterIDLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 655, EditPrinterw, 30)];
    EditprinterIDLabel.text = @"Printer ID";
    EditprinterIDLabel.backgroundColor=[UIColor clearColor];
    EditprinterIDLabel.textColor=[UIColor whiteColor];
    EditprinterIDLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditprinterIDLabel];
     if (!EditprinteridTF)
    EditprinteridTF = [[UITextField alloc]initWithFrame:CGRectMake(EditPrinterw, 685, EditPrinterw, 30)];
    EditprinteridTF.text=printerid;
    EditprinteridTF.borderStyle= UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditprinteridTF];
     if (!EditipAddressLabel)
    EditipAddressLabel = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw, 715, EditPrinterw, 30)];
    EditipAddressLabel.text= @"IP Address/PortName";
    EditipAddressLabel.backgroundColor=[UIColor clearColor];
    EditipAddressLabel.textColor=[UIColor whiteColor];
    EditipAddressLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditipAddressLabel];
    if (!EditipAddressTF)
    EditipAddressTF = [[UITextField alloc]initWithFrame:CGRectMake(EditPrinterw, 745, EditPrinterw, 30)];
    EditipAddressTF.text=Ipadd;
    EditipAddressTF.borderStyle= UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditipAddressTF];
    
    if (!EditfontTableView)
    EditfontTableView = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw, 116, 200, 100) style:UITableViewStylePlain];
    EditfontTableView.backgroundColor=[UIColor whiteColor];
    EditfontTableView.delegate = self;
    EditfontTableView.dataSource = self;
    EditfontTableView.scrollEnabled = YES;
    EditfontTableView.hidden=YES;
    [EditfontTableView.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditfontTableView.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditfontTableView];
    if (!EditalignLineSpaTV)
    EditalignLineSpaTV = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw, 178, 200, 100) style:UITableViewStylePlain];
    EditalignLineSpaTV.backgroundColor=[UIColor whiteColor];
    EditalignLineSpaTV.delegate = self;
    EditalignLineSpaTV.dataSource = self;
    EditalignLineSpaTV.scrollEnabled = YES;
    EditalignLineSpaTV.hidden=YES;
    [EditalignLineSpaTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditalignLineSpaTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditalignLineSpaTV];
     if (!EditlanguageTV)
    EditlanguageTV = [[UITableView alloc]initWithFrame:CGRectMake(EditPrinterw, 238, 200, 100) style:UITableViewStylePlain];
    EditlanguageTV.backgroundColor=[UIColor whiteColor];
    EditlanguageTV.delegate = self;
    EditlanguageTV.dataSource = self;
    EditlanguageTV.scrollEnabled = YES;
    EditlanguageTV.hidden=YES;
    [EditlanguageTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditlanguageTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditlanguageTV];
    
     if (!EditsizeWidthTV)
    EditsizeWidthTV = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw, 298, EditPrinterw/2, 100) style:UITableViewStylePlain];
    EditsizeWidthTV.backgroundColor=[UIColor whiteColor];
    EditsizeWidthTV.delegate = self;
    EditsizeWidthTV.dataSource = self;
    EditsizeWidthTV.scrollEnabled = YES;
    EditsizeWidthTV.hidden=YES;
    [EditsizeWidthTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditsizeWidthTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditsizeWidthTV];
     if (!EditsizeHeightTV)
    EditsizeHeightTV = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw+sizeButton.frame.size.width+5, 298, EditPrinterw/2, 100) style:UITableViewStylePlain];
    EditsizeHeightTV.backgroundColor=[UIColor whiteColor];
    EditsizeHeightTV.delegate = self;
    EditsizeHeightTV.dataSource = self;
    EditsizeHeightTV.scrollEnabled = YES;
    EditsizeHeightTV.hidden=YES;
    [EditsizeHeightTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditsizeHeightTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditsizeHeightTV];
     if (!EditPrinterTypesTable)
    EditPrinterTypesTable = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw, 568, 200, 100) style:UITableViewStylePlain];
    EditPrinterTypesTable.backgroundColor=[UIColor whiteColor];
    EditPrinterTypesTable.delegate = self;
    EditPrinterTypesTable.dataSource = self;
    EditPrinterTypesTable.scrollEnabled = YES;
    EditPrinterTypesTable.hidden=YES;
    [EditPrinterTypesTable.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditPrinterTypesTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditPrinterTypesTable];
    
     if (!EditprinterNameTV)
    EditprinterNameTV = [[UITableView alloc] initWithFrame:CGRectMake(EditPrinterw, 628, 200, 100) style:UITableViewStylePlain];
    EditprinterNameTV.backgroundColor=[UIColor whiteColor];
    EditprinterNameTV.delegate = self;
    EditprinterNameTV.dataSource = self;
    EditprinterNameTV.scrollEnabled = YES;
    EditprinterNameTV.hidden=YES;
    [EditprinterNameTV.layer setBorderWidth: 2.0];
    //[titlesdata_table.layer setCornerRadius:8.0f];
    //[titlesdata_table.layer setMasksToBounds:YES];
    [EditprinterNameTV.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditPrinterView addSubview:EditprinterNameTV];
    if (!EditLignSpacelbl)
    EditLignSpacelbl = [[UILabel alloc]initWithFrame:CGRectMake(EditPrinterw,775, EditPrinterw, 30)];
    EditLignSpacelbl.text= @"Line Spacing";
    EditLignSpacelbl.backgroundColor=[UIColor clearColor];
    EditLignSpacelbl.textColor=[UIColor whiteColor];
    EditLignSpacelbl.font = [UIFont systemFontOfSize:20.0f];
    [EditPrinterView addSubview:EditLignSpacelbl];
     if (!EditalignLineSpaTF)
    EditalignLineSpaTF = [[UITextField alloc]initWithFrame:CGRectMake(EditPrinterw, 805, EditPrinterw, 30)];
    EditalignLineSpaTF.text=spacing;
    EditalignLineSpaTF.borderStyle= UITextBorderStyleRoundedRect;
    [EditPrinterView addSubview:EditalignLineSpaTF];
    
    EditsaveButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    EditsaveButton.frame= CGRectMake(EditPrinterw,850, EditPrinterw, 40);
    [EditsaveButton setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    EditsaveButton.titleLabel.font = [UIFont systemFontOfSize:20.0f];
    [EditsaveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditsaveButton addTarget:self action:@selector(saveEditPrinterData) forControlEvents:UIControlEventTouchUpInside];
    //[addprinterdataView addSubview:printerNameButton];
    [EditsaveButton setTitle:@"Save" forState:UIControlStateNormal];
    [EditPrinterView addSubview:EditsaveButton];

}
- (IBAction)printer_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    SelectedPrinter=but.tag-1;
    PrinterAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Printer Data" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [PrinterAlert show];
}
- (IBAction)tax_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    NSInteger  selectedrow=but.tag-1;
    if (!edittaxpopup)
    edittaxpopup=[[UIView alloc]init];
    if (isLandScope) {
        edittaxpopup.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        edittaxpopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [edittaxpopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:edittaxpopup];
     if (!EdittaxBackView)
    EdittaxBackView=[[UIScrollView alloc]init];
    if (isLandScope){
        EdittaxBackView.frame=CGRectMake(200,75, edittaxpopup.frame.size.width-400, edittaxpopup.frame.size.height-200);
    }else{
        EdittaxBackView.frame=CGRectMake(75,200, edittaxpopup.frame.size.width-150, edittaxpopup.frame.size.height-500);
    }
    [EdittaxBackView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [EdittaxBackView.layer setBorderWidth:2.0];
    [EdittaxBackView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    EdittaxBackView.layer.cornerRadius=8;
    [edittaxpopup addSubview:EdittaxBackView];
    
    
      NSString *querySQL2 = [NSString stringWithFormat: @"SELECT tax_value,name FROM taxes"];
    NSMutableArray *taxesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxesArray];
    NSDictionary *Dict=[taxesArray objectAtIndex:selectedrow];
    
    name=[Dict objectForKey:@"name"];
    taxrate= [Dict objectForKey:@"tax_value"];
   
  
    
    CGFloat changewidth=(EdittaxBackView.frame.size.width)/2;
    CGFloat k=(changewidth/2)+20;
     if (!taxnamelbl)
    taxnamelbl=[[UILabel alloc]init];
    taxnamelbl.frame=CGRectMake(k,150 ,100, 50);
    [taxnamelbl setText:@"Name"];
    [taxnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [taxnamelbl setBackgroundColor:[UIColor clearColor]];
    [taxnamelbl setTextColor:[UIColor whiteColor]];
    [EdittaxBackView addSubview:taxnamelbl];
     if (!changetaxField)
    changetaxField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    changetaxField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 160, 200, 30);
    changetaxField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    changetaxField.leftView = paddingview;
    changetaxField.leftViewMode = UITextFieldViewModeAlways;
    [changetaxField setText:name];
    changetaxField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [changetaxField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [changetaxField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EdittaxBackView addSubview:changetaxField];
    if (!ratetaxlbl)
    ratetaxlbl=[[UILabel alloc]init];
    ratetaxlbl.frame=CGRectMake(k,250 ,100, 50);
    [ratetaxlbl setText:@"Rate"];
    [ratetaxlbl setBackgroundColor:[UIColor clearColor]];
    [ratetaxlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ratetaxlbl setTextColor:[UIColor whiteColor]];
    [EdittaxBackView addSubview:ratetaxlbl];
    if (!changerateField)
    changerateField=[[UITextField alloc] init];
    changerateField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 260, 200, 30);
    changerateField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    changerateField.leftView = paddingview2;
    changerateField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    changerateField.leftViewMode = UITextFieldViewModeAlways;
    [changerateField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [changerateField setText:taxrate];
    //[RateTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    [changerateField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [changerateField setKeyboardType:UIKeyboardTypeNumberPad];
    [EdittaxBackView addSubview:changerateField];
    
    @autoreleasepool {
        changesavetax = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        changesavetax.frame=CGRectMake(k+taxnamelbl.frame.size.width-20, 340, 80, 30);
        [changesavetax addTarget:self action:@selector(saveedittax) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [changesavetax setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [changesavetax setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [EdittaxBackView addSubview:changesavetax];
        
        changecanceltax = [UIButton buttonWithType:UIButtonTypeRoundedRect];
         changecanceltax.frame=CGRectMake(k+taxnamelbl.frame.size.width+80, 340, 80, 30);
        [changecanceltax addTarget:self action:@selector(canceledittax) forControlEvents:UIControlEventTouchUpInside];
        [changecanceltax setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [changecanceltax setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        
        [EdittaxBackView addSubview:changecanceltax];
    }
   
    
}
- (IBAction)payment_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag-1);
    
   
    NSInteger  selectedrow=but.tag-1;
    if (!editPaymentPopup)
    editPaymentPopup=[[UIView alloc]init];
    if (isLandScope){
        editPaymentPopup.frame=CGRectMake(0, 0, 1024, 748);
    }else{
        
        editPaymentPopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [editPaymentPopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:editPaymentPopup];
    NSString *querySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
    NSMutableArray *paymentsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:paymentsArray];
    NSDictionary *dict=[paymentsArray objectAtIndex:selectedrow];

    payNameStr=[dict objectForKey:@"payment_name"];
    payValueStr= [dict objectForKey:@"payment_value"];
   
    
    CGFloat lwidth=(editPaymentPopup.frame.size.width)/2;
    CGFloat position=(lwidth/2)+20;
     if (!paynameLbl)
    paynameLbl=[[UILabel alloc]init];
    paynameLbl.frame=CGRectMake(position,150 ,100, 50);
    [paynameLbl setText:@"Name"];
    [paynameLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [paynameLbl setBackgroundColor:[UIColor clearColor]];
    [paynameLbl setTextColor:[UIColor whiteColor]];
    [editPaymentPopup addSubview:paynameLbl];
    if (!payNametext)
    payNametext=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    payNametext.frame=CGRectMake(position+paynameLbl.frame.size.width+10, 158, 230, 40);
    payNametext.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    payNametext.leftView = paddingview;
    payNametext.leftViewMode = UITextFieldViewModeAlways;
    [payNametext setText:payNameStr];
    payNametext.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [payNametext setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [payNametext setAutocorrectionType:UITextAutocorrectionTypeNo];
    [editPaymentPopup addSubview:payNametext];
    if (!payValuelbl)
    payValuelbl=[[UILabel alloc]init];
    payValuelbl.frame=CGRectMake(position,203 ,100, 50);
    [payValuelbl setText:@"Tax"];
    [payValuelbl setBackgroundColor:[UIColor clearColor]];
    [payValuelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [payValuelbl setTextColor:[UIColor whiteColor]];
    [editPaymentPopup addSubview:payValuelbl];
    if (!payEnableBtn)
    payEnableBtn = [[UIButton alloc] initWithFrame:CGRectMake(position+paynameLbl.frame.size.width+10,220, 20, 20)];
    [payEnableBtn setTag:0];
    [payEnableBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
    [payEnableBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    
    [payEnableBtn addTarget:self action:@selector(radiobuttonSelected2:) forControlEvents:UIControlEventTouchUpInside];
     if (!payDisableBtn)
    payDisableBtn = [[UIButton alloc] initWithFrame:CGRectMake(position+paynameLbl.frame.size.width+10,255, 20, 20)];
    [payDisableBtn setTag:1];
    [payDisableBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
    [payDisableBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    [payDisableBtn addTarget:self action:@selector(radiobuttonSelected2:) forControlEvents:UIControlEventTouchUpInside];
    if ([payValueStr isEqualToString:@"yes"]){
        [payEnableBtn setSelected:YES];
        //[[OriginalDB getSharedInstance]setPaymentvalue:@"YES"];
    }else  if ([payValueStr isEqualToString:@"no"]){
        [payDisableBtn setSelected:YES];
       // [[OriginalDB getSharedInstance]setPaymentvalue:@"NO"];
    }
    [editPaymentPopup addSubview:payEnableBtn];
    [editPaymentPopup addSubview:payDisableBtn];
    if (!enablePaylbl)
    enablePaylbl=[[UILabel alloc]init];
    enablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,213 ,100, 30);
    [enablePaylbl setText:@"Enable"];
    [enablePaylbl setFont:[UIFont systemFontOfSize:20.0f]];
    [enablePaylbl setBackgroundColor:[UIColor clearColor]];
    [enablePaylbl setTextColor:[UIColor whiteColor]];
    [editPaymentPopup addSubview:enablePaylbl];
    if (!disablePaylbl)
    disablePaylbl=[[UILabel alloc]init];
    disablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,251 ,100, 30);
    [disablePaylbl setText:@"Disable"];
    [disablePaylbl setFont:[UIFont systemFontOfSize:20.0f]];
    [disablePaylbl setBackgroundColor:[UIColor clearColor]];
    [disablePaylbl setTextColor:[UIColor whiteColor]];
    [editPaymentPopup addSubview:disablePaylbl];
    @autoreleasepool {
        SaveChangePayBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        SaveChangePayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width-40, 320, 80, 30);
        [SaveChangePayBtn addTarget:self action:@selector(SvaeChangePay) forControlEvents:UIControlEventTouchUpInside];
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveChangePayBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveChangePayBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [editPaymentPopup addSubview:SaveChangePayBtn];
        
        CancelpayBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelpayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width+100, 320, 80, 30);
        [CancelpayBtn addTarget:self action:@selector(CancelChangePay) forControlEvents:UIControlEventTouchUpInside];
        [CancelpayBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [CancelpayBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [editPaymentPopup addSubview:CancelpayBtn];
    }
    
}

- (IBAction)payment_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag-1);
 
    selectedPayment=but.tag-1;
    deletePaymentAlert=[[UIAlertView alloc]initWithTitle:@"message" message:@"Are you sure you want delete the Payment" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deletePaymentAlert show];
}
- (IBAction)tax_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag-1);
    
  
    selectedTax=but.tag-1;
    deletetaxAlert=[[UIAlertView alloc]initWithTitle:@"message" message:@"Are you sure you want delete the tax" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deletetaxAlert show];
}
-(void)saveEditPrinterData
{
    NSString *Font=[NSString stringWithFormat:@"%@",EditfontButton.titleLabel.text];
    NSString *align=[NSString stringWithFormat:@"%@",EditalignLineSpaButton.titleLabel.text];
    NSString *language=[NSString stringWithFormat:@"%@",EditlanguageButton.titleLabel.text];
    NSString *Swidth=[NSString stringWithFormat:@"%@",EditsizeButton.titleLabel.text];
    NSString *Sheight=[NSString stringWithFormat:@"%@",EditwidthButton.titleLabel.text];
    NSString *printername=[NSString stringWithFormat:@"%@",EditprinterNameButton.titleLabel.text];
    
     NSString *printertype=[NSString stringWithFormat:@"%@",EditPrinterTypeBtn.titleLabel.text];
    
    NSString *insertSQL =@"UPDATE printer SET  headlines=?, language=?,unit=?,spacing=?,fontsize=?,align=?,Wsize=?,Hsize=?,bold=?,underline=?,Xposition=?,printname=?,ipaddress=?,printer_type=?,searchprinter=? WHERE print_id=? ";
    
  NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:EditprinterCharTF.text,language,EditfeedUnitTF.text,EditalignLineSpaTF.text,Font,align,Swidth,Sheight,Bold,Underline,EditxPositionTF.text,printername,EditipAddressTF.text,printertype,SearchPrinterStr,EditprinteridTF.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:updateArray];
    
    NSArray *EditPrinterViewArray = EditPrinterView.subviews;
    for (int i = 0; i<[EditPrinterViewArray count]; i++) {
        UIView *vi =[EditPrinterViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *EditPrinterPopUpViewArray = EditPrinterPopUpView.subviews;
    for (int i = 0; i<[EditPrinterPopUpViewArray count]; i++) {
        UIView *vi =[EditPrinterPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditPrinterView removeFromSuperview],[EditPrinterPopUpView removeFromSuperview];
    
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Printer data successfully saved." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    
     [self GetprinterDatamethod];
    [editPrinterTable reloadData];
    Font=nil;
    align=nil;
    language=nil;
    Swidth=nil;
    Sheight=nil;
    printername=nil;
    printertype=nil;
    insertSQL=nil;
    
}


-(void)EditboldSwitchClick: (UISwitch *)sender
{
    if (sender.on){
        Bold=@"0";
        [sender setOn:FALSE animated:YES];
        
    }else{
        Bold=@"1";
        [sender setOn:TRUE animated:YES];
    }
    
    
}
-(void)EditunderlineSwitchClick : (UISwitch *)sender
{
    if (sender.on){
        Underline=@"0";
        [sender setOn:FALSE animated:YES];
    }else{
        Underline=@"1";
        [sender setOn:TRUE animated:YES];
    }
}
-(void)EditalignLineSpaceClick
{
    if (EditalignLineSpaTV.hidden==1){
        
        [EditalignLineSpaTV setHidden:NO];
        
        EditlanguageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (EditalignLineSpaTV.hidden==0){
        [EditalignLineSpaTV setHidden:YES];
        
        EditlanguageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
    
}
-(void)EditlanguageButtonClick
{
    if (EditlanguageTV.hidden==1){
        
        [EditlanguageTV setHidden:NO];
        
        EditsizeButton.hidden=YES;
        
        //languageButton.hidden=YES;
        //printermethodBtn.hidden=YES;
        
    }else if (EditlanguageTV.hidden==0){
        [EditlanguageTV setHidden:YES];
        
        EditsizeButton.hidden=NO;
        
        //languageButton.hidden=NO;
        //printermethodBtn.hidden=NO;
    }
    
    // //NSLog(@"called");
    
}
-(void)EditsizeClick
{
    if (EditsizeWidthTV.hidden==1){
        
        [EditsizeWidthTV setHidden:NO];
      
    }else if (EditsizeWidthTV.hidden==0)
    {
        [EditsizeWidthTV setHidden:YES];
    }
  
}
-(void)EditwidthClick
{
    if (EditsizeHeightTV.hidden==1){
        
        [EditsizeHeightTV setHidden:NO];
        
    }else if (EditsizeHeightTV.hidden==0){
        [EditsizeHeightTV setHidden:YES];
        
    }
 
}
-(void)EditFontsizesetClick
{
    
    if (EditfontTableView.hidden==1){
        [EditfontTableView setHidden:NO];
        
        EditalignLineSpaButton.hidden=YES;
        
    } else if (EditfontTableView.hidden==0){
        [EditfontTableView setHidden:YES];
        
        EditalignLineSpaButton.hidden=NO;
    }
    
}
-(void)EditprinterTypeClick
{
    if (EditPrinterTypesTable.hidden==1){
        [EditPrinterTypesTable setHidden:NO];
        
    }else if (EditPrinterTypesTable.hidden==0){
        [EditPrinterTypesTable setHidden:YES];
    }
}
-(void)EditprinterNameClick
{
    if (EditprinterNameTV.hidden==1){
        [EditprinterNameTV setHidden:NO];
        
    }else  if (EditprinterNameTV.hidden==0){
        [EditprinterNameTV setHidden:YES];
    }
}

-(void)DepartmentCheckBox:(UIButton *)sender
{
    DepartmentsArray=[[NSMutableArray alloc]init];
   NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    for (NSDictionary *myDict in deptsArray)
    {
        [DepartmentsArray addObject:[myDict objectForKey:@"department_id"]];
        
    }
    NSInteger selectedDept=sender.tag;
    if (sender.selected){
        sender.selected=NO;
       
        NSString *deptstr=[DepartmentsArray objectAtIndex:selectedDept];
        NSString *updateSQL6 =@"UPDATE department_details SET check_value=?  WHERE vdepartment_id=?";
        NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:@"false",deptstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL6 withArguments:updateArray];
        deptstr=nil,updateSQL6=nil;
    }else if(!sender.selected){
        sender.selected=YES;
       
       NSString *deptstr=[DepartmentsArray objectAtIndex:selectedDept];
        NSString *updateSQL6 =@"UPDATE department_details SET check_value=?  WHERE vdepartment_id=?";
        NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:@"true",deptstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL6 withArguments:updateArray];
        deptstr=nil,updateSQL6=nil;
    }
  
    
}
-(void)ItemCheckBox:(UIButton *)sender
{
    NSInteger selecteditem=sender.tag;
    
    if (sender.selected){
        sender.selected=NO;
        
        NSString *deptstr=[ItemsArray objectAtIndex:selecteditem];
        NSString *updateSQL6 =@"UPDATE inventorytable SET check_value=? WHERE inventary_item_name=?";
        NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:@"false",deptstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL6 withArguments:updateArray];
        deptstr=nil,updateSQL6=nil;
    }else if(!sender.selected){
       
        NSString *deptstr=[ItemsArray objectAtIndex:selecteditem];
        NSString *updateSQL6 =@"UPDATE inventorytable SET check_value=?  WHERE inventary_item_name=?";
        NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:@"true",deptstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL6 withArguments:updateArray];
        deptstr=nil,updateSQL6=nil;
        sender.selected=YES;
    }
}

-(void)saveedittax
{
  
    NSString *changetax=changetaxField.text;
    NSString *changerate=changerateField.text;
  
  
    NSString *updateSQL = @"UPDATE taxes SET name=?, tax_value=? WHERE name=? ";
    NSMutableArray *taxsArray=[[NSMutableArray alloc]initWithObjects:changetax,changerate,name, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:taxsArray];
    NSString *querySQL2 = [NSString stringWithFormat: @"SELECT name,tax_value FROM taxes"];
    taxDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxDataArray];
    [edittaxpopup removeFromSuperview];
    [edittaxTable reloadData];
    
    NSString *invupdateStr=@"update inventorytable set inventary_taxone=REPLACE (inventary_taxone,?,?) where inventary_taxone LIKE '%%%?%%'";
    
    NSMutableArray *invupdateArray=[[NSMutableArray alloc]initWithObjects:name,changetax,name, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:invupdateStr withArguments:invupdateArray];
    
    NSString *DeptupdateStr=@"update department_details set department_totaltax= REPLACE(department_totaltax,?,?) where department_totaltax LIKE '%%%?%%'";
    
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:DeptupdateStr withArguments:invupdateArray];
    
    EdittaxArray=[[NSMutableArray alloc]init];
    [EdittaxArray addObject:[NSString stringWithFormat:@"update inventorytable set inventary_taxone=REPLACE (inventary_taxone,'%@','%@') where inventary_taxone LIKE '%%%@%%'",name,changetax,name]];
    [EdittaxArray addObject:DeptupdateStr];
    //NSError *err;
    
    //NSData *jsonData = [NSJSONSerialization dataWithJSONObject:EdittaxArray options:kNilOptions error:&err];
    //NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
  //NSLog(@"query strs %@",str);
    if(![generalDataObject  connectedToInternet]){
        
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"edit",[generalDataObject  userID],@"execute.php?",invupdateStr,@"",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {

           NSString *bodyString;
            
            bodyString  = [NSString stringWithFormat:@"query-string=%@",[invupdateStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
          // bodyString=[NSString stringWithFormat:@"query-string=%@",str];
            NSString *urlstring=[NSString stringWithFormat:@"%@execute.php?",[generalDataObject  OriginalbaseURLstr]];
            
            //// //NSLog(@"%@",bodyString);
            //// //NSLog(@"%@",urlstring);
            
            NSMutableURLRequest *request= [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlstring]];
            //// //NSLog(@"%@",request);
            
            [request setTimeoutInterval:20.0];
            
            NSData *requestData = [NSData dataWithBytes:[bodyString UTF8String] length:[bodyString length]];
           // // //NSLog(@"requst data %@",requestData);
            
            [request setHTTPMethod:@"POST"];
          [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            
           [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        [request setValue:[NSString stringWithFormat:@"%d", [bodyString length]] forHTTPHeaderField:@"Content-Length"];
            [request setHTTPBody:requestData];
            //// //NSLog(@"%@",request);
            
            InvConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [InvConnection start];
           
            }
        
        }
    
    if(![generalDataObject  connectedToInternet]){
        
        
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"edit",[generalDataObject  userID],@"execute.php?",DeptupdateStr,@"",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0){
           
            NSString *bodyString;
            
            bodyString  = [NSString stringWithFormat:@"query-string=%@",[DeptupdateStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // bodyString=[NSString stringWithFormat:@"query-string=%@",str];
            NSString *urlstring=[NSString stringWithFormat:@"%@execute.php?",[generalDataObject  OriginalbaseURLstr]];
            
           // // //NSLog(@"%@",bodyString);
           // // //NSLog(@"%@",urlstring);
            
            NSMutableURLRequest *request= [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlstring]];
           // // //NSLog(@"%@",request);
            
            [request setTimeoutInterval:20.0];
            
            NSData *requestData = [NSData dataWithBytes:[bodyString UTF8String] length:[bodyString length]];
            // // //NSLog(@"requst data %@",requestData);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            
            [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            [request setValue:[NSString stringWithFormat:@"%d", [bodyString length]] forHTTPHeaderField:@"Content-Length"];
            [request setHTTPBody:requestData];
           // // //NSLog(@"%@",request);
            
            DeptConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [DeptConnection start];
        }
      
    }
}
-(void)canceledittax
{
    [edittaxpopup removeFromSuperview];
}

-(void)SvaeChangePay
{
   
    
    NSString *updateSQL2 =@"UPDATE payments SET payment_name=?, payment_value=? WHERE payment_name=?";
    NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:payNametext.text,@"yes",payNameStr,nil];
    
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL2 withArguments:updateArray];
    [editPaymentPopup removeFromSuperview];
    
    NSString *querySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
    paymentDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:paymentDataArray];
    [PaymentTable reloadData];

}
-(void)CancelChangePay
{
    [editPaymentPopup removeFromSuperview];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
{
    if (alertView==SynAlertview && buttonIndex==0){
        TotalServerSynClass *totalServerSyncClassObject=[TotalServerSynClass new];
        
        [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:totalServerSyncClassObject withObject:nil];
        
        
    }else if (alertView==deletetaxAlert && buttonIndex==0){
        
        NSString *querySQL2 = [NSString stringWithFormat: @"SELECT tax_value,name FROM taxes"];
        NSMutableArray *taxesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxesArray];
        NSDictionary *Dict=[taxesArray objectAtIndex:selectedTax];
        NSString *taxname=[Dict objectForKey:@"name"];
        
        NSString *updateSQL =@"DELETE FROM taxes WHERE name=?";
        NSMutableArray *deleteArray=[[NSMutableArray alloc]initWithObjects:taxname, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteArray];
        NSString *querySQL3= [NSString stringWithFormat: @"SELECT name,tax_value FROM taxes"];
        taxDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:taxDataArray];
        [edittaxTable reloadData];
        
    }else if (alertView==deletePaymentAlert && buttonIndex==0){
       
        NSString *querySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
        NSMutableArray *paymentsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL3 resultsArray:paymentsArray];
        NSDictionary *dict=[paymentsArray objectAtIndex:selectedPayment];
        
        payNameStr=[dict objectForKey:@"payment_name"];
        NSString *updateSQL =@"DELETE FROM payments WHERE payment_name=?";
        NSMutableArray *deleteArray=[[NSMutableArray alloc]initWithObjects:payNameStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteArray];
        NSString *selectquerySQL3 = [NSString stringWithFormat: @"SELECT payment_name,payment_value FROM payments"];
        paymentDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL3 resultsArray:paymentDataArray];
        
        [PaymentTable reloadData];
        
    }else if (alertView==PrinterAlert && buttonIndex==0){
       
         NSString *pName=[printernamesArray objectAtIndex:SelectedPrinter];
       
       NSString *updateSQL =@"DELETE FROM printer WHERE printname=?";
        NSMutableArray *deleteArray=[[NSMutableArray alloc]initWithObjects:pName, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteArray];
     
        [self GetprinterDatamethod];
       
       [editPrinterTable reloadData];
     
   }else if (alertView==SavecompanyAlert && buttonIndex==0){

       if(![generalDataObject  connectedToInternet]){
           
       }else if([generalDataObject  connectedToInternet])
       {
           NSString *string=[NSString stringWithFormat:@"http://192.168.1.6/xampp/sites/aone/crm/serverurl.php?companyid=%@",[CompanyTextF.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
           
           NSURL *url=[NSURL URLWithString:string];
           NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
           RegisterConnection = [NSURLConnection connectionWithRequest:request delegate:self];
           
           [RegisterConnection start];
       }
   }else if (alertView==ServerUrlAlert && buttonIndex==0){
       
       NSMutableArray *DatabasetablesArray=[[NSMutableArray alloc] initWithObjects:@"department_details",@"category_details",@"vendor",@"inventorytable",@"optional_info_table",@"ordering_info_table",@"alternate_sku",@"modifier_table",@"customer_table",@"customer_general_info_table",@"customer_extended_info_table",@"customer_shipping_table",@"customer_stores_table",@"employee_permissions",@"employee_payroll",@"employee_personal",@"employee_table",@"store_details",@"employee_store",@"invoice_items_table",@"invoice_total_table",@"taxes",@"printer",@"printer_commands",@"pending_queries",@"payments",@"admin_details",@"department_printer_commands",@"split_invoice_table",@"merchant_info_table",@"mercury_pay_table",@"paymentprocessorpreferencess",@"login_logout_table", nil];
       for (int i=0; i<[DatabasetablesArray count]; i++)
       {
           NSString *selectedTable=[DatabasetablesArray objectAtIndex:i];
           NSString *deletesql=[NSString stringWithFormat:@"DELETE FROM %@",selectedTable];
           NSMutableArray *deleteArray=[[NSMutableArray alloc]init];
           [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletesql withArguments:deleteArray];
           
       }

       NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
       NSMutableArray *updateArray=[[NSMutableArray alloc]init];
       [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
       
       if ([updateArray count]==0){
           NSString *insertSQL =  @"insert into miscellaneous (pageurl) values(?)";
           NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:ServerurlStr, nil];
           [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
           
           NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
           NSMutableArray *updateArray=[[NSMutableArray alloc]init];
           [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
           
           NSString *pageUrl;
           if ([updateArray count]>0){
               
               for (NSDictionary *Dict in updateArray)
               {
                   pageUrl=[Dict objectForKey:@"pageurl"];
                   
               }
           }
           [generalDataObject  setOriginalbaseURLstr:pageUrl];
           
       }else{
          NSString *insertSQL = @"UPDATE miscellaneous SET pageurl=?";
           NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:ServerurlStr, nil];
           [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
           
           NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
           NSMutableArray *updateArray=[[NSMutableArray alloc]init];
           [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
           NSString *pageUrl;
           if ([updateArray count]>0){
               
               for (NSDictionary *Dict in updateArray)
               {
                   pageUrl=[Dict objectForKey:@"pageurl"];
                   
               }
           }
           [generalDataObject  setOriginalbaseURLstr:pageUrl];
       }
       
       
        [self.navigationController popToRootViewControllerAnimated:YES];
       [self releaseViews];
   }
    
    
}


- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    if (connection == connection1){
        if ([(NSHTTPURLResponse *)response statusCode] == 200) {
            ServerUrlAlert=[[UIAlertView alloc]initWithTitle:@"message" message:@"All local data will be deleted and You will be automatically loggedout?" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
            [ServerUrlAlert show];
            // url exists
        }else{
         UIAlertView   *Alert=[[UIAlertView alloc]initWithTitle:@"message" message:@"Url does not exist Type correct Url." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            [Alert show];
        }
    }else if (connection == RegisterConnection){
        RegisterResponseData = [[NSMutableData alloc] init];
    }else if (connection == InvConnection){
        InvResponseData = [[NSMutableData alloc] init];
    }else if (connection == DeptConnection){
        DeptResponseData = [[NSMutableData alloc] init];
    }else if (connection == CardConnection){
        cardResponseData = [[NSMutableData alloc] init];
    }
    
   
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    if (connection == RegisterConnection){
        [RegisterResponseData appendData:data];
    }else if (connection == InvConnection){
        [InvResponseData appendData:data];
    }else if (connection == DeptConnection){
        [DeptResponseData appendData:data];
    }else if (connection == CardConnection){
        [cardResponseData appendData:data];
    }
    
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if (connection==RegisterConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[RegisterResponseData mutableBytes] length:[RegisterResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        //// //NSLog(@"register data %@",dataDict);
        NSString *result=[[dataDict objectForKey:@"response"] objectForKey:@"result"];
        
        int resultvalue=[result intValue];
        
       NSString *Statusstr=[[dataDict objectForKey:@"response"] objectForKey:@"serverurl"];
        
        if (resultvalue==0){
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Failed" message:Statusstr delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
            [alert show];
        }else if (resultvalue==1){
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Success" message:Statusstr delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
            [alert show];
            CompanyTextF.text=@"";
            
            NSMutableArray *DatabasetablesArray=[[NSMutableArray alloc] initWithObjects:@"department_details",@"category_details",@"vendor",@"inventorytable",@"optional_info_table",@"ordering_info_table",@"alternate_sku",@"modifier_table",@"customer_table",@"customer_general_info_table",@"customer_extended_info_table",@"customer_shipping_table",@"customer_stores_table",@"employee_permissions",@"employee_payroll",@"employee_personal",@"employee_table",@"store_details",@"employee_store",@"invoice_items_table",@"invoice_total_table",@"taxes",@"printer",@"printer_commands",@"pending_queries",@"payments",@"admin_details",@"department_printer_commands",@"split_invoice_table", nil];
            for (int i=0; i<[DatabasetablesArray count]; i++)
            {
                NSString *selectedTable=[DatabasetablesArray objectAtIndex:i];
                NSString *deletesql=[NSString stringWithFormat:@"DELETE FROM %@",selectedTable];
                NSMutableArray *deleteArray=[[NSMutableArray alloc]init];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletesql withArguments:deleteArray];
                
            }
            
            NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
            NSMutableArray *updateArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
            
            if ([updateArray count]==0){
                NSString *insertSQL =  @"insert into miscellaneous (pageurl) values(?)";
                NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:ServerurlStr, nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
                
                NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
                NSMutableArray *updateArray=[[NSMutableArray alloc]init];
                [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
                
                NSString *pageUrl;
                if ([updateArray count]>0){
                    
                    for (NSDictionary *Dict in updateArray)
                    {
                        pageUrl=[Dict objectForKey:@"pageurl"];
                        
                    }
                }
                [generalDataObject  setOriginalbaseURLstr:pageUrl];
                
            }else{
                NSString *insertSQL = @"UPDATE miscellaneous SET pageurl=?";
                NSMutableArray *insertArray=[[NSMutableArray alloc]initWithObjects:ServerurlStr, nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertArray];
                
                NSString *querySQL = [NSString stringWithFormat: @"SELECT pageurl FROM miscellaneous"];
                NSMutableArray *updateArray=[[NSMutableArray alloc]init];
                [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:updateArray];
                NSString *pageUrl;
                if ([updateArray count]>0){
                    
                    for (NSDictionary *Dict in updateArray)
                    {
                        pageUrl=[Dict objectForKey:@"pageurl"];
                        
                    }
                }
                [generalDataObject  setOriginalbaseURLstr:pageUrl];
            }
            

            [self.navigationController popToRootViewControllerAnimated:YES];
            
            
        }
     responseStr=nil;
    }else if (connection==InvConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[InvResponseData mutableBytes] length:[InvResponseData length] encoding:NSUTF8StringEncoding];
       // // //NSLog(@"%@",responseStr);
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
       // // //NSLog(@"repose  data %@",dataDict);
        
        
        NSString *Servertime=[[dataDict objectForKey:@"response"] objectForKey:@"server-time"];
        NSString *selectQuery=[NSString stringWithFormat:@"select selected_store, local_time,pageurl,last_server_update_time from miscellaneous"];
        NSMutableArray *mislaneousArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectQuery resultsArray:mislaneousArray];
        
        if ([mislaneousArray count]>0){
            NSString *updateSQL =@"UPDATE miscellaneous SET last_server_update_time=?";
            NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:Servertime, nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
        }else{
            NSString *insertSQL =@"insert into miscellaneous (selected_store,local_time,pageurl,last_server_update_time) values(?,?,?,?)";
            NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"Store1",[generalDataObject getsystemDatetime],[generalDataObject  OriginalbaseURLstr],Servertime, nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:misUpdatearray];
        }
         responseStr=nil;
        
    }else if (connection==DeptConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[DeptResponseData mutableBytes] length:[DeptResponseData length] encoding:NSUTF8StringEncoding];
       // // //NSLog(@"%@",responseStr);
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
       // // //NSLog(@"repose  data %@",dataDict);
        
        
        NSString *Servertime=[[dataDict objectForKey:@"response"] objectForKey:@"server-time"];
        //// //NSLog(@"server time %@",Servertime);
        NSString *selectQuery=[NSString stringWithFormat:@"select selected_store, local_time,pageurl,last_server_update_time from miscellaneous"];
        NSMutableArray *mislaneousArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectQuery resultsArray:mislaneousArray];
        
        if ([mislaneousArray count]>0){
            NSString *updateSQL =@"UPDATE miscellaneous SET last_server_update_time=?";
            NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:Servertime, nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
        }else{
            NSString *insertSQL =@"insert into miscellaneous (selected_store,local_time,pageurl,last_server_update_time) values(?,?,?,?)";
            NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"Store1",[generalDataObject getsystemDatetime],[generalDataObject  OriginalbaseURLstr],Servertime, nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:misUpdatearray];
        }  responseStr=nil;
        
    }else if (connection == CardConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[cardResponseData mutableBytes] length:[cardResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        responseStr=nil;
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
        
        
    }
    dataDict=nil;
}
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
    if ( gesture.state == UIGestureRecognizerStateEnded ) {
        //// //NSLog(@"Long Press");
    }
}
- (BOOL)shouldAutorotate
{
    return YES;
}
-(void)updateUI
{
    if (isLandScope){
        
         [DeptCheckBox setFrame:CGRectMake(320, 10, 25, 25)];
        [ItemCheckBox setFrame:CGRectMake(320, 10, 25, 25)];
        
        CGFloat width,height;
        width=1024;
        height=748;
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        
        
       // sidemenu.frame=CGRectMake(0, 1,170 ,height-150);//need to be remove
        //sidemenu.hidden=YES;
        
        [categorybutton setFrame:CGRectMake(0,p,170,40)];
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        // mainview.frame=CGRectMake(sidemenu.frame.size.width+10,0,width-(sidemenu.frame.size.width+20),height-150);
        mainview.frame=CGRectMake(10,60,width-20,height-200);
        
        [backgroundcolorview addSubview:mainview];
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        CGFloat barbuttonwidth=(mainview.frame.size.width)/8;
        Applicationbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20, 60);
        Printerbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        taxbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);
        
        paymentbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        
        DBbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        dataresetbarbtn.frame = CGRectMake(0, 0, barbuttonwidth,60);
        
         CompanyBtn.frame = CGRectMake(0, 0, barbuttonwidth-10,60);
        CardBtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);

        
        scrollView.frame = maintoolBar.frame;
        
        //application view
        ApplicationView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        addApplicationDataView.frame=CGRectMake(10, 10, ApplicationView.frame.size.width-20, ApplicationView.frame.size.height-20);
        
        CGFloat Btnwdth=(addApplicationDataView.frame.size.width)/3;
        DeptBtn.frame=CGRectMake(40,40,Btnwdth+40,40);

        DepartmentsTable .frame= CGRectMake(40,79,Btnwdth+40,200);
       
        
        ItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+100,40,Btnwdth+40,40);
        ItemsTable .frame= CGRectMake(40+DeptBtn.frame.size.width+100,79,Btnwdth+40,200);
        
        saveDeptsBtn.frame=CGRectMake(130,79+250,80,30);
        SaveItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+190,79+250,80,30);
        
//tax view
         TaxView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        CGFloat addbuttonwidth=(TaxView.frame.size.width-10)/2;
        addtaxBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
         editTaxButton.frame=CGRectMake(addtaxBtn.frame.size.width, 10, addbuttonwidth, 40);
        AddTaxView.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
        
        
        CGFloat labelwidth=(AddTaxView.frame.size.width)/2;
        CGFloat x=(labelwidth/2)+60;
        
        namelabel.frame=CGRectMake(x,50 ,100, 50);
        RateLabel.frame=CGRectMake(x,150 ,100, 50);
        nameTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 60, 200, 30);
        
        
        RateTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 160, 200, 30);
        
        SaveTaxButton.frame=CGRectMake(x+namelabel.frame.size.width-20, 240, 80, 30);
        
        
        CancelTaxButton.frame=CGRectMake(x+namelabel.frame.size.width+80, 240, 80, 30);
        edittaxTable.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
        
//Edit tax view
        
         edittaxpopup.frame=CGRectMake(0, 0, 1024, 768);
       
        
        EdittaxBackView.frame=CGRectMake(200,75, edittaxpopup.frame.size.width-400, edittaxpopup.frame.size.height-200);
   
       // EdittaxBackView.frame=CGRectMake(75,200, edittaxpopup.frame.size.width-150, edittaxpopup.frame.size.height-500);
        
         CGFloat changewidth=(EdittaxBackView.frame.size.width)/2;
        CGFloat k=(changewidth/2)+20;
        
        taxnamelbl.frame=CGRectMake(k,150 ,100, 50);
    
        changetaxField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 160, 200, 30);
        
        
        ratetaxlbl.frame=CGRectMake(k,250 ,100, 50);
        
        changerateField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 260, 200, 30);
        
        changesavetax.frame=CGRectMake(k+taxnamelbl.frame.size.width-20, 340, 80, 30);
      changecanceltax.frame=CGRectMake(k+taxnamelbl.frame.size.width+80, 340, 80, 30);
        
        //payment view
        paymentview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
      
        CGFloat buttonwidth=(paymentview.frame.size.width-10)/2;
        addpaymentBtn.frame=CGRectMake(10, 10, buttonwidth, 40);
        
        editpaymentBtn.frame=CGRectMake(addpaymentBtn.frame.size.width, 10, buttonwidth, 40);
        AddpaymentView.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
        
        
        CGFloat labelwidth2=(AddpaymentView.frame.size.width)/2;
        CGFloat m=(labelwidth2/2)+20;
      
        paymentnamelbl.frame=CGRectMake(m,50 ,100, 50);
        paymentnameField.frame=CGRectMake(m+paymentnamelbl.frame.size.width+10, 58, 230, 40);
       
        paymenttaxlbl.frame=CGRectMake(m,103 ,100, 50);
        
        paymentenableradioBtn .frame=CGRectMake(m+paymentnamelbl.frame.size.width+10,120, 20, 20);
               paymentdisableradioBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width+10,155, 20, 20);
       
        enablepaymentlbl.frame=CGRectMake(m+paymentnamelbl.frame.size.width+40,113 ,100, 30);
        disablepaymentlbl.frame=CGRectMake(m+paymentnamelbl.frame.size.width+40,151 ,100, 30);
        savepaymentBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width-40, 220, 80, 30);
        cancelpaymentBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width+100, 220, 80, 30);
       
        PaymentTable.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
          editPaymentPopup.frame=CGRectMake(0, 0, 1024, 768);
        CGFloat lwidth=(editPaymentPopup.frame.size.width)/2;
        CGFloat position=(lwidth/2)+20;
      
        paynameLbl.frame=CGRectMake(position,150 ,100, 50);

        payNametext.frame=CGRectMake(position+paynameLbl.frame.size.width+10, 158, 230, 40);
        payValuelbl.frame=CGRectMake(position,203 ,100, 50);
    payEnableBtn .frame=CGRectMake(position+paynameLbl.frame.size.width+10,220, 20, 20);
    payDisableBtn .frame=CGRectMake(position+paynameLbl.frame.size.width+10,255, 20, 20);
    enablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,213 ,100, 30);
    disablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,251 ,100, 30);
       SaveChangePayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width-40, 320, 80, 30);
        CancelpayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width+100, 320, 80, 30);
        
//data reset view
        
        dataresetView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        Resetview.frame=CGRectMake(10, 10, dataresetView.frame.size.width-20, dataresetView.frame.size.height-20);
       
        CGFloat startingPosition=(Resetview.frame.size.width/4)-80;
      
        Titlelbl.frame=CGRectMake(startingPosition,43 ,300, 50);
      
        setYesBtn.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width-10,60, 20, 20);
     
        yeslbl.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10,45 ,55, 50);
       
        setNoBtn.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10+yeslbl.frame.size.width+10,60, 20, 20);
       
        Nolbl.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10+yeslbl.frame.size.width+30+setNoBtn.frame.size.width,45 ,55, 50);
      
        resetAllBtn.frame=CGRectMake(startingPosition+100,100, 40, 40);
       
        resetAllLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     95,150, 50);
       
        ProductsLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     145,150, 50);
        
        selllLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                  195,150, 50);
       
        customerlbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     245,150, 50);
       
        ProductsBtn.frame=CGRectMake(startingPosition+100,150, 40, 40);
       
        SellBtn.frame=CGRectMake(startingPosition+100,200, 40, 40);
    
        CustomerBtn.frame=CGRectMake(startingPosition+100,250, 40, 40);
        
        textLabel.frame=CGRectMake(150,300,Resetview.frame.size.width-200, 50);
         resetButton.frame=CGRectMake((Resetview.frame.size.width/2)-100,350, 150, 40);
        
//printer view
        
        printerview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
      
        addprinterdataView.frame=CGRectMake(10, 10, printerview.frame.size.width-20, printerview.frame.size.height-20);
         addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2+200);
        CGFloat labelwidth3=(addprinterdataView.frame.size.width/4);
        int b=20;
        for (int i=0; i<10; i++)
        {
            UILabel *mylabel=(UILabel *)[addprinterdataView viewWithTag:i+100];
            mylabel.frame=CGRectMake(211, b, labelwidth3+60, 40);
            [addprinterdataView addSubview:mylabel];
          // // //NSLog(@"%f",mylabel.frame.origin.x);
           
            b=b+60;
        }
        int s=20;
        for (int i=0; i < 4; i++)
        {
            UITextField *mytextfield=(UITextField *)[addprinterdataView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, s,labelwidth3, 40);
            [addprinterdataView addSubview:mytextfield];
            s=s+60;
        }
        
        alignButton.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,260, labelwidth3, 40);
        
        fontsizeBtn.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,320, labelwidth3, 40);
        printermethodBtn.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,380, labelwidth3, 40);
        printernameField.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 440,labelwidth3, 40);
        printeridField.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 500,labelwidth3, 40);
        
        textlbl.frame=CGRectMake(labelwidth3-60,addprinterdataView.frame.size.height+100,addprinterdataView.frame.size.width-40, 30);
       
        updateButton.frame=CGRectMake(labelwidth3+30,addprinterdataView.frame.size.height+150, 150, 50);
       
        getprinterstatusBtn.frame=CGRectMake(labelwidth3+updateButton.frame.size.width+100,addprinterdataView.frame.size.height+150, 200, 50);
        
        
    aligndataTable.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 301,labelwidth3,100);
        
    fontsTable.frame = CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 361,labelwidth3,100);printermethodsTable.frame =CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 421,labelwidth3,100);
        
        //DB Backup View
        DbbackUpview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
       
        addDBBackupView.frame=CGRectMake(10, 10, printerview.frame.size.width-20, printerview.frame.size.height-20);
        
        
//Company View
       
        CompanyBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
       
        CompanyView.frame=CGRectMake(10, 10, CompanyBackView.frame.size.width-20, CompanyBackView.frame.size.height-20);
        
        CGFloat Homewdth=(CompanyView.frame.size.width)/2;
        
        CompanyTextF.frame=CGRectMake(Homewdth-220, 40, Homewdth-100, 40);
    
        SubmitCmpyBtn.frame=CGRectMake(CompanyTextF.frame.size.width+Homewdth-200,40, 100, 40);
      
      //  HomeImageView.frame=CGRectMake((Homewdth/2)-50,100,Homewdth+100,300);
        
     //  HomeImageBtn.frame=CGRectMake(Homewdth-120,440,Homewdth-100,40);
  
 //Printer  Data View
        
        printerview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CGFloat addbuttonwidth2=(printerview.frame.size.width-10)/2;
        addPrintButton.frame=CGRectMake(10, 10, addbuttonwidth2, 40);
        
        editPrinterButton.frame=CGRectMake(addPrintButton.frame.size.width, 10, addbuttonwidth2, 40);
        
        addprinterdataView.frame=CGRectMake(10, 10+addPrintButton.frame.size.height, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
        addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2+200);
       
        editPrinterTable.frame=CGRectMake(10, addPrintButton.frame.size.height+10, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
       
        
        CGFloat Printerw=addprinterdataView.frame.size.width/3;
        
        printCharLabel .frame= CGRectMake(Printerw, 20, Printerw, 30);
       
        
        printerCharTF.frame = CGRectMake(Printerw, 55, Printerw, 30);
        
        
        fontLabel .frame= CGRectMake(Printerw, 85, Printerw, 30);
        
        fontButton.frame=CGRectMake(Printerw, 115, 200, 30);
        
        alignLineSpaLabel.frame = CGRectMake(Printerw, 145, Printerw, 30);
       
        alignLineSpaButton.frame=CGRectMake(Printerw, 175, Printerw, 30);
        
        
        langLabel .frame=CGRectMake(Printerw, 205, Printerw, 30);
        
      
        languageButton.frame=CGRectMake(Printerw, 235, 200, 30);
        
        
        sizeLabel.frame =CGRectMake(Printerw, 265, Printerw, 30);
      
        sizeButton.frame=CGRectMake(Printerw, 295, Printerw/2, 30);
        
        widthButton.frame=CGRectMake(Printerw+sizeButton.frame.size.width+5, 295, Printerw/2, 30);
    
        
        styleLabel.frame =CGRectMake(Printerw, 325, Printerw/2, 30);
        
        boldLabel .frame= CGRectMake(Printerw+10, 355, Printerw/2, 30);
        
        boldSwitch.frame=CGRectMake(Printerw+10+boldLabel.frame.size.width, 355, 100, 30);
      
        
        underLineLabel.frame = CGRectMake(Printerw+10, 385, Printerw, 30);
       
        
        underlineSwitch.frame= CGRectMake(Printerw+10+boldLabel.frame.size.width, 390, 100, 30);
        
        
        xPositionLabel .frame=CGRectMake(Printerw, 415, Printerw, 30);
     
        
        xPositionTF.frame = CGRectMake(Printerw, 445, Printerw, 30);
        
        feedUnitLabel.frame = CGRectMake(Printerw, 475, Printerw, 30);
       
        
        feedUnitTF .frame= CGRectMake(Printerw, 505, Printerw, 30);
        

        
        PrinterTypeLabel .frame= CGRectMake(Printerw, 535, Printerw, 30);
      
        PrinterTypeBtn.frame=CGRectMake(Printerw, 565, 200, 30);
        
        PrinterNameLabel.frame = CGRectMake(Printerw, 595, Printerw, 30);
      
        printerNameButton.frame=CGRectMake(Printerw,625, 200, 30);
      
         Printer1Label.frame=CGRectMake(Printerw+Printerw+10, 645, 150, 100);
        printerIDLabel.frame =CGRectMake(Printerw, 655, Printerw, 30);
     
        printeridTF.frame = CGRectMake(Printerw, 685, Printerw, 30);
        
        ipAddressLabel.frame = CGRectMake(Printerw, 715, Printerw, 30);
    
        ipAddressTF .frame= CGRectMake(Printerw, 745, Printerw, 30);
        
         PrinterTypesTable.frame = CGRectMake(Printerw, 568, 200, 100);
        
        fontTableView .frame= CGRectMake(Printerw, 116, 200, 100);
        
        alignLineSpaTV.frame =CGRectMake(Printerw, 178, 200, 100);
        
        languageTV .frame= CGRectMake(Printerw, 238, 200, 100);
        
        sizeWidthTV .frame=CGRectMake(Printerw, 298, Printerw/2, 100);
       
        sizeHeightTV.frame =CGRectMake(Printerw+sizeButton.frame.size.width+5, 298, Printerw/2, 100);
        
        
        printerNameTV.frame = CGRectMake(Printerw, 628, 200, 100);
        
        LignSpacelbl .frame=CGRectMake(Printerw,775, Printerw, 30);
     alignLineSpaTF .frame= CGRectMake(Printerw, 805, Printerw, 30);
        
        saveButton.frame= CGRectMake(Printerw,850, Printerw, 40);
        wifiLabel.frame=CGRectMake(Printerw+Printerw+5, 565, 50, 30);
        wifi_Switch.frame=CGRectMake(Printerw+Printerw+55, 565, 100, 30);
       btLabel .frame=CGRectMake(Printerw+Printerw+125, 565, 100, 30);

 //Edit Printer View
        
        EditPrinterPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        
        //EditPrinterPopUpView.frame=CGRectMake(0, 0, 768, 1024);
  
    EditPrinterView.frame=CGRectMake(50,30, EditPrinterPopUpView.frame.size.width-100, EditPrinterPopUpView.frame.size.height-60);
    EditPrinterView.contentSize=CGSizeMake(EditPrinterPopUpView.frame.size.width-100,EditPrinterPopUpView.frame.size.height+500);
    
    CGFloat EditPrinterw=EditPrinterView.frame.size.width/3;
    
    EditprintCharLabel .frame=CGRectMake(EditPrinterw, 20, EditPrinterw, 30);
    
    EditprinterCharTF.frame = CGRectMake(EditPrinterw, 55, EditPrinterw, 30);
    
    EditfontLabel.frame = CGRectMake(EditPrinterw, 85, EditPrinterw, 30);
   
    EditfontButton.frame=CGRectMake(EditPrinterw, 115, 200, 30);
   
    EditalignLineSpaLabel .frame= CGRectMake(EditPrinterw, 145, EditPrinterw, 30);
   
    EditalignLineSpaButton.frame=CGRectMake(EditPrinterw, 175, 200, 30);
    
    EditlangLabel .frame= CGRectMake(EditPrinterw, 205, EditPrinterw, 30);
   
    EditlanguageButton.frame=CGRectMake(EditPrinterw, 235, 200, 30);
    
    
    EditsizeLabel .frame= CGRectMake(EditPrinterw, 265, EditPrinterw, 30);
   
    EditsizeButton.frame=CGRectMake(EditPrinterw, 295, EditPrinterw/2, 30);
   
    EditwidthButton.frame=CGRectMake(EditPrinterw+EditsizeButton.frame.size.width+5, 295, EditPrinterw/2, 30);
    
    EditstyleLabel .frame= CGRectMake(EditPrinterw, 325, EditPrinterw/2, 30);
    
    EditboldLabel .frame=CGRectMake(EditPrinterw+10, 355, EditPrinterw/2, 30);
    
    EditboldSwitch.frame=CGRectMake(EditPrinterw+10+EditboldLabel.frame.size.width, 355, 100, 30);
    
    EditunderLineLabel .frame=CGRectMake(EditPrinterw+10, 385, EditPrinterw, 30);
   
    EditunderlineSwitch.frame=CGRectMake(EditPrinterw+10+boldLabel.frame.size.width, 390, 100, 30);
    
    EditxPositionLabel .frame=CGRectMake(EditPrinterw, 415, EditPrinterw, 30);

    EditxPositionTF.frame =CGRectMake(EditPrinterw, 445, EditPrinterw, 30);

    EditfeedUnitLabel.frame = CGRectMake(EditPrinterw, 475, EditPrinterw, 30);
    
    EditfeedUnitTF .frame=CGRectMake(EditPrinterw, 505, EditPrinterw, 30);

        EditPrintertypelabel .frame= CGRectMake(EditPrinterw, 535, EditPrinterw, 30);
      
        EditPrinterTypeBtn.frame=CGRectMake(EditPrinterw, 565, 200, 30);
      
        
        EditPrinterNameLabel.frame = CGRectMake(EditPrinterw, 595, EditPrinterw, 30);
        
       
        EditprinterNameButton.frame=CGRectMake(EditPrinterw, 625, 200, 30);
        
        EditprinterIDLabel.frame = CGRectMake(EditPrinterw, 655, EditPrinterw, 30);
        
        EditprinteridTF .frame= CGRectMake(EditPrinterw, 685, EditPrinterw, 30);
        
        EditipAddressLabel.frame =CGRectMake(EditPrinterw, 715, EditPrinterw, 30);
     
        
        EditipAddressTF .frame=CGRectMake(EditPrinterw, 745, EditPrinterw, 30);

    EditfontTableView.frame = CGRectMake(EditPrinterw, 116, 200, 100) ;
    
    EditalignLineSpaTV.frame = CGRectMake(EditPrinterw, 178, 200, 100) ;

    EditlanguageTV.frame =CGRectMake(EditPrinterw, 238, 200, 100);
    
    EditsizeWidthTV.frame = CGRectMake(EditPrinterw, 298, EditPrinterw/2, 100);
    
    EditsizeHeightTV.frame = CGRectMake(EditPrinterw+sizeButton.frame.size.width+5, 298, EditPrinterw/2, 100);
    EditPrinterTypesTable.frame = CGRectMake(EditPrinterw, 568, 200, 100);
    EditprinterNameTV .frame= CGRectMake(EditPrinterw, 628, 200, 100);
    
    EditLignSpacelbl.frame = CGRectMake(EditPrinterw,775, EditPrinterw, 30);

    EditalignLineSpaTF.frame =CGRectMake(EditPrinterw, 805, EditPrinterw, 30);
   
    EditsaveButton.frame= CGRectMake(EditPrinterw,850, EditPrinterw, 40);
    editwifiLabel.frame = CGRectMake(EditPrinterw+EditPrinterw+5, 565, 50, 30);
      
    editwifi_Switch.frame=CGRectMake(EditPrinterw+EditPrinterw+55, 565, 100, 30);
      
    editbtLabel.frame =CGRectMake(EditPrinterw+EditPrinterw+125, 565, 100, 30);
        
//Server Url View
        ServerUrlBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
      
        ServerView.frame=CGRectMake(10, 10, ServerUrlBackView.frame.size.width-20, ServerUrlBackView.frame.size.height-20);
    
        CGFloat ServerW=ServerView.frame.size.width/3;
        ServerUrllbl.frame=CGRectMake(ServerW-60,100 ,150, 50);
        ServerTextView.frame= CGRectMake(ServerW+ServerUrllbl.frame.size.width-100, 107, ServerW+100, 40);
        
        SaveServerUrlBtn.frame=CGRectMake(ServerW+50+ServerW/2,160, 100, 40);
        
        
//Card View
        
        
        CardBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
      
        CardView.frame=CGRectMake(10, 10, CardBackView.frame.size.width-20, CardBackView.frame.size.height-20);
        CardView.contentSize=CGSizeMake( CardBackView.frame.size.width-20, CardBackView.frame.size.height+100);
       
        
        CGFloat CardW=CardView.frame.size.width/2;
        CGFloat cardX=CardW/2;
        
       
        paymentLabel.frame=CGRectMake(cardX-100,30 ,300,40);
        
        paymentButton.frame=CGRectMake(cardX-100, 80, 250, 40);
        paymentTableView .frame=CGRectMake(cardX-100, 120, 250, 80) ;
       
        primaryurllbl.frame=CGRectMake(cardX-100,150 ,180,40);
      
        PrimaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 150, CardW,40);
       
        Securllbl.frame=CGRectMake(cardX-100,210 ,180,40);
        
        SecondaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 210, CardW,40);
        
        
        merchantNolbl.frame=CGRectMake(cardX-100,270 ,180,40);
      
        MerchantField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 270, CardW,40);
        
       
        terminalNolbl.frame=CGRectMake(cardX-100,330 ,180,40);
      
        TerminalField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 330, CardW,40);
        
   
        
        ProcessBtn.frame=CGRectMake(cardX-80,395 ,30,30);
     
        Processdebittextlbl.frame=CGRectMake(cardX-30,390,CardW+CardW/2, 40);
        
        
        RequireBtn.frame=CGRectMake(cardX-80,445 ,30,30);
      
        requiretextlbl.frame=CGRectMake(cardX-30,440,CardW+CardW/2, 40);
     
        saveCardDataBtn.frame= CGRectMake(CardW-40,520, 100, 40);
    timeoutlbl.frame=CGRectMake(cardX-100,390 ,180,40);
    timeoutTextField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 390, CardW,40);

 //Company view
        
        HomeImageView.frame=CGRectMake(20,20,Homewdth-80,Homewdth-80);
        
        HomeImageBtn.frame=CGRectMake(40,Homewdth-40,Homewdth-80,40);
               
        //merchant view
        CGFloat merchantW=CompanyView.frame.size.width/2;
       
        merchantDataLabel .frame=CGRectMake(merchantW+60, 20, merchantW, 30);
      
        merchantNameLabel.frame=CGRectMake(merchantW+10, 80, 100, 30);
       
        merchantnameTf .frame=CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 80,  merchantW/2, 30);

        addressLabel.frame =CGRectMake(merchantW+10, 140,100, 30);
     
        addressTf.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 140, merchantW/2, 30);
      
        addressLabel2.frame=CGRectMake(merchantW+10, 200,100, 30);
       
        addressTf2.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 200, merchantW/2, 30);
       
        phNoLabel.frame =CGRectMake(merchantW+10, 260,100, 30);
        
        phNoTf.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 260, merchantW/2, 30);
        
        zipcodeLabel.frame =CGRectMake(merchantW+10, 320, 100, 30);
    
        zipcodeTf.frame=CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 320,  merchantW/2, 30);
       savemerchantDataBtn.frame= CGRectMake(merchantW+100,380, 100, 40);
    }else{
        
        [DeptCheckBox setFrame:CGRectMake(240, 10, 25, 25)];
        [ItemCheckBox setFrame:CGRectMake(240, 10, 25, 25)];
        
        CGFloat width,height;
        height=1004;
        width=768;
        //// //NSLog(@" %f,%f",width,height);
        
        
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        
       // sidemenu.frame=CGRectMake(0, 1,170 ,height-150);//need to be remove
        // sidemenu.hidden=YES;
        [categorybutton setFrame:CGRectMake(0,p,170,40)];
        mainview.frame=CGRectMake(10,60,width-20,height-200);
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        //downtoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        scrollView.frame = maintoolBar.frame;
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        CGFloat barbuttonwidth=(mainview.frame.size.width)/8;
        Applicationbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20, 60);
       
        
        Printerbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        taxbarbtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);
        
        paymentbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        
        DBbarbtn.frame = CGRectMake(0, 0, barbuttonwidth, 60);
        
        dataresetbarbtn.frame = CGRectMake(0, 0, barbuttonwidth,60);
        CompanyBtn.frame = CGRectMake(0, 0, barbuttonwidth-10,60);
    
           CardBtn.frame = CGRectMake(0, 0, barbuttonwidth-20,60);
        
        //Application view
        
        
        ApplicationView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        addApplicationDataView.frame=CGRectMake(10, 10, ApplicationView.frame.size.width-20, ApplicationView.frame.size.height-20);
        
        CGFloat Btnwdth=(addApplicationDataView.frame.size.width)/3;
        DeptBtn.frame=CGRectMake(40,40,Btnwdth+40,40);
        
        DepartmentsTable .frame= CGRectMake(40,79,Btnwdth+40,200);
        
        
        ItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+100,40,Btnwdth+40,40);
        ItemsTable .frame= CGRectMake(40+DeptBtn.frame.size.width+100,79,Btnwdth+40,200);
        
        saveDeptsBtn.frame=CGRectMake(130,79+250,80,30);
        SaveItemsBtn.frame=CGRectMake(40+DeptBtn.frame.size.width+190,79+250,80,30);
        
        
        //tax view
       
         TaxView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        CGFloat addbuttonwidth=(TaxView.frame.size.width-10)/2;
        addtaxBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
         editTaxButton.frame=CGRectMake(addtaxBtn.frame.size.width, 10, addbuttonwidth, 40);
        AddTaxView.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
        
        
        CGFloat labelwidth=(AddTaxView.frame.size.width)/2;
        CGFloat x=(labelwidth/2)+20;
        
        namelabel.frame=CGRectMake(x,50 ,100, 50);
        RateLabel.frame=CGRectMake(x,150 ,100, 50);
        nameTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 60, 200, 30);
        RateTextfield.frame=CGRectMake(x+namelabel.frame.size.width+30, 160, 200, 30);
        
        SaveTaxButton.frame=CGRectMake(x+namelabel.frame.size.width-20, 240, 80, 30);
        CancelTaxButton.frame=CGRectMake(x+namelabel.frame.size.width+80, 240, 80, 30);
        
      edittaxTable.frame=CGRectMake(10, addtaxBtn.frame.size.height+10, TaxView.frame.size.width-20, TaxView.frame.size.height-20-addtaxBtn.frame.size.height);
   //Edit tax View
        
         edittaxpopup.frame=CGRectMake(0, 0, 768, 1024);
        
         EdittaxBackView.frame=CGRectMake(75,200, edittaxpopup.frame.size.width-150, edittaxpopup.frame.size.height-500);
        
        CGFloat changewidth=(EdittaxBackView.frame.size.width)/2;
        
        CGFloat k=(changewidth/2)+20;
      
        taxnamelbl.frame=CGRectMake(k,150 ,100, 50);
        
        changetaxField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 160, 200, 30);
        
        
        ratetaxlbl.frame=CGRectMake(k,250 ,100, 50);
        
        changerateField.frame=CGRectMake(k+taxnamelbl.frame.size.width+30, 260, 200, 30);
        
        changesavetax.frame=CGRectMake(k+taxnamelbl.frame.size.width-20, 340, 80, 30);
        changecanceltax.frame=CGRectMake(k+taxnamelbl.frame.size.width+80, 340, 80, 30);
        
        //payment view
        paymentview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CGFloat buttonwidth=(paymentview.frame.size.width-10)/2;
        addpaymentBtn.frame=CGRectMake(10, 10, buttonwidth, 40);
        
        editpaymentBtn.frame=CGRectMake(addpaymentBtn.frame.size.width, 10, buttonwidth, 40);
        AddpaymentView.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
        
        
        CGFloat labelwidth2=(AddpaymentView.frame.size.width)/2;
        CGFloat m=(labelwidth2/2)+20;
        
        paymentnamelbl.frame=CGRectMake(m,50 ,100, 50);
        paymentnameField.frame=CGRectMake(m+paymentnamelbl.frame.size.width+10, 58, 230, 40);
        
        paymenttaxlbl.frame=CGRectMake(m,103 ,100, 50);
        
        paymentenableradioBtn .frame=CGRectMake(m+paymentnamelbl.frame.size.width+10,120, 20, 20);
        paymentdisableradioBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width+10,155, 20, 20);
        
        enablepaymentlbl.frame=CGRectMake(m+paymentnamelbl.frame.size.width+40,113 ,100, 30);
        disablepaymentlbl.frame=CGRectMake(m+paymentnamelbl.frame.size.width+40,151 ,100, 30);
        savepaymentBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width-40, 220, 80, 30);
        cancelpaymentBtn.frame=CGRectMake(m+paymentnamelbl.frame.size.width+100, 220, 80, 30);
        
        PaymentTable.frame=CGRectMake(10, addpaymentBtn.frame.size.height+10, paymentview.frame.size.width-20, paymentview.frame.size.height-20-addpaymentBtn.frame.size.height);
          editPaymentPopup.frame=CGRectMake(0, 0, 768, 1024);
        CGFloat lwidth=(editPaymentPopup.frame.size.width)/2;
        CGFloat position=(lwidth/2)+20;
        
        paynameLbl.frame=CGRectMake(position,150 ,100, 50);
        
        payNametext.frame=CGRectMake(position+paynameLbl.frame.size.width+10, 158, 230, 40);
        payValuelbl.frame=CGRectMake(position,203 ,100, 50);
        payEnableBtn .frame=CGRectMake(position+paynameLbl.frame.size.width+10,220, 20, 20);
        payDisableBtn .frame=CGRectMake(position+paynameLbl.frame.size.width+10,255, 20, 20);
        enablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,213 ,100, 30);
        disablePaylbl.frame=CGRectMake(position+paynameLbl.frame.size.width+40,251 ,100, 30);
        SaveChangePayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width-40, 320, 80, 30);
        CancelpayBtn.frame=CGRectMake(position+paynameLbl.frame.size.width+100, 320, 80, 30);
//data reset view
        
        dataresetView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        Resetview.frame=CGRectMake(10, 10, dataresetView.frame.size.width-20, dataresetView.frame.size.height-20);
        
        CGFloat startingPosition=(Resetview.frame.size.width/4)-80;
        
        Titlelbl.frame=CGRectMake(startingPosition,43 ,300, 50);
        
        setYesBtn.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width-10,60, 20, 20);
        
        yeslbl.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10,45 ,55, 50);
        
        setNoBtn.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10+yeslbl.frame.size.width+10,60, 20, 20);
        
        Nolbl.frame=CGRectMake(startingPosition+Titlelbl.frame.size.width+setYesBtn.frame.size.width+10+yeslbl.frame.size.width+30+setNoBtn.frame.size.width,45 ,55, 50);
        
        resetAllBtn.frame=CGRectMake(startingPosition+100,100, 40, 40);
        
        resetAllLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     95,150, 50);
        
        ProductsLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     145,150, 50);
        
        selllLbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                  195,150, 50);
        
        customerlbl.frame=CGRectMake(startingPosition+resetAllBtn.frame.size.width+120,
                                     245,150, 50);
        
        ProductsBtn.frame=CGRectMake(startingPosition+100,150, 40, 40);
        
        SellBtn.frame=CGRectMake(startingPosition+100,200, 40, 40);
        
        CustomerBtn.frame=CGRectMake(startingPosition+100,250, 40, 40);
        
        textLabel.frame=CGRectMake(30,300,Resetview.frame.size.width-40, 50);
         resetButton.frame=CGRectMake((Resetview.frame.size.width/2)-80,350, 150, 40);
    
//printer view
        
        printerview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        addprinterdataView.frame=CGRectMake(10, 10, printerview.frame.size.width-20, printerview.frame.size.height-20);
         addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2);
        CGFloat labelwidth3=(addprinterdataView.frame.size.width/4);
        int b=20;
        for (int i=0; i<10; i++)
        {
            UILabel *mylabel=(UILabel *)[addprinterdataView viewWithTag:i+100];
            mylabel.frame=CGRectMake(labelwidth3-30, b, labelwidth3+60, 40);
            [addprinterdataView addSubview:mylabel];
            
            
            b=b+60;
        }
        int s=20;
        for (int i=0; i< 4; i++)
        {
            UITextField *mytextfield=(UITextField *)[addprinterdataView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, s,labelwidth3, 40);
            [addprinterdataView addSubview:mytextfield];
            s=s+60;
        }
        
        alignButton.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,260, labelwidth3, 40);
        
        fontsizeBtn.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,320, labelwidth3, 40);
        printermethodBtn.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20,380, labelwidth3, 40);
        printernameField.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 440,labelwidth3, 40);
        printeridField.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 500,labelwidth3, 40);
        textlbl.frame=CGRectMake(labelwidth3-60,addprinterdataView.frame.size.height-180,addprinterdataView.frame.size.width-40, 30);
        
        updateButton.frame=CGRectMake(labelwidth3,addprinterdataView.frame.size.height-150, 150, 50);
        
        getprinterstatusBtn.frame=CGRectMake(labelwidth3+updateButton.frame.size.width+60,addprinterdataView.frame.size.height-150, 200, 50);
        
        aligndataTable.frame=CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 301,labelwidth3,100);
        
        fontsTable.frame = CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 361,labelwidth3,100);printermethodsTable.frame =CGRectMake(labelwidth3+fieldslbl.frame.size.width-20, 421,labelwidth3,100);
        
//DB Backup View
        DbbackUpview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        addDBBackupView.frame=CGRectMake(10, 10, printerview.frame.size.width-20, printerview.frame.size.height-20);
    
//Company View
        
        CompanyBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CompanyView.frame=CGRectMake(10, 10, CompanyBackView.frame.size.width-20, CompanyBackView.frame.size.height-20);
        
        CGFloat Homewdth=(CompanyView.frame.size.width)/2;
        
        CompanyTextF.frame=CGRectMake(Homewdth-220, 40, Homewdth-100, 40);
        
        SubmitCmpyBtn.frame=CGRectMake(CompanyTextF.frame.size.width+Homewdth-200,40, 100, 40);
        
       // HomeImageView.frame=CGRectMake((Homewdth/2)-50,100,Homewdth+100,300);
        
       // HomeImageBtn.frame=CGRectMake(Homewdth-120,440,Homewdth-100,40);
        
//Printer  Data View
        
        printerview.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CGFloat addbuttonwidth2=(printerview.frame.size.width-10)/2;
        addPrintButton.frame=CGRectMake(10, 10, addbuttonwidth2, 40);
        
        editPrinterButton.frame=CGRectMake(addPrintButton.frame.size.width, 10, addbuttonwidth2, 40);
        
        addprinterdataView.frame=CGRectMake(10, 10+addPrintButton.frame.size.height, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
        addprinterdataView.contentSize=CGSizeMake(printerview.frame.size.width-20,printerview.frame.size.height*2);
        
        editPrinterTable.frame=CGRectMake(10, addPrintButton.frame.size.height+10, printerview.frame.size.width-20, printerview.frame.size.height-20-addPrintButton.frame.size.height);
        
        
        CGFloat Printerw=addprinterdataView.frame.size.width/3;
        
        printCharLabel .frame= CGRectMake(Printerw, 20, Printerw, 30);
        
        
        printerCharTF.frame = CGRectMake(Printerw, 55, Printerw, 30);
        
        
        fontLabel .frame= CGRectMake(Printerw, 85, Printerw, 30);
        
        fontButton.frame=CGRectMake(Printerw, 115, 200, 30);
        
        alignLineSpaLabel.frame = CGRectMake(Printerw, 145, Printerw, 30);
        
        alignLineSpaButton.frame=CGRectMake(Printerw, 175, 200, 30);
        
        
        langLabel .frame=CGRectMake(Printerw, 205, Printerw, 30);
        
        
        languageButton.frame=CGRectMake(Printerw, 235, 200, 30);
        
        
        sizeLabel.frame =CGRectMake(Printerw, 265, Printerw, 30);
        
        sizeButton.frame=CGRectMake(Printerw, 295, Printerw/2, 30);
        
        widthButton.frame=CGRectMake(Printerw+sizeButton.frame.size.width+5, 295, Printerw/2, 30);
        
        
        styleLabel.frame =CGRectMake(Printerw, 325, Printerw/2, 30);
        
        boldLabel .frame= CGRectMake(Printerw+10, 355, Printerw/2, 30);
        
        boldSwitch.frame=CGRectMake(Printerw+10+boldLabel.frame.size.width, 355, 100, 30);
        
        
        underLineLabel.frame = CGRectMake(Printerw+10, 385, Printerw, 30);
        
        
        underlineSwitch.frame= CGRectMake(Printerw+10+boldLabel.frame.size.width, 390, 100, 30);
        
        
        xPositionLabel .frame=CGRectMake(Printerw, 415, Printerw, 30);
        
        
        xPositionTF.frame = CGRectMake(Printerw, 445, Printerw, 30);
        
        feedUnitLabel.frame = CGRectMake(Printerw, 475, Printerw, 30);
        
        
        feedUnitTF .frame= CGRectMake(Printerw, 505, Printerw, 30);
        
        PrinterTypeLabel .frame= CGRectMake(Printerw, 535, Printerw, 30);
        
        PrinterTypeBtn.frame=CGRectMake(Printerw, 565, 200, 30);
        
        PrinterNameLabel.frame = CGRectMake(Printerw, 595, Printerw, 30);
        
        printerNameButton.frame=CGRectMake(Printerw,625, 200, 30);
        
         Printer1Label.frame=CGRectMake(Printerw+Printerw+10, 645, 150, 100);
        
        printerIDLabel.frame =CGRectMake(Printerw, 655, Printerw, 30);
        
        printeridTF.frame = CGRectMake(Printerw, 685, Printerw, 30);
        
        ipAddressLabel.frame = CGRectMake(Printerw, 715, Printerw, 30);
        
        ipAddressTF .frame= CGRectMake(Printerw, 745, Printerw, 30);
        
        PrinterTypesTable.frame = CGRectMake(Printerw, 568, 200, 100);
        
        fontTableView .frame= CGRectMake(Printerw, 116, 200, 100);
        
        alignLineSpaTV.frame =CGRectMake(Printerw, 178, 200, 100);
        
        languageTV .frame= CGRectMake(Printerw, 238, 200, 100);
        
        sizeWidthTV .frame=CGRectMake(Printerw, 298, Printerw/2, 100);
        
        sizeHeightTV.frame =CGRectMake(Printerw+sizeButton.frame.size.width+5, 298, Printerw/2, 100);
        
        
        printerNameTV.frame = CGRectMake(Printerw, 628, 200, 100);
        
        LignSpacelbl .frame=CGRectMake(Printerw,775, Printerw, 30);
        alignLineSpaTF .frame= CGRectMake(Printerw, 805, Printerw, 30);
        
        saveButton.frame= CGRectMake(Printerw,850, Printerw, 40);
        wifiLabel.frame=CGRectMake(Printerw+Printerw+5, 565, 50, 30);
        wifi_Switch.frame=CGRectMake(Printerw+Printerw+55, 565, 100, 30);
        btLabel .frame=CGRectMake(Printerw+Printerw+125, 565, 100, 30);
//Edit Printer View
        
       // EditPrinterPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        
        
        EditPrinterPopUpView.frame=CGRectMake(0, 0, 768, 1024);
        
        EditPrinterView.frame=CGRectMake(50,30, EditPrinterPopUpView.frame.size.width-100, EditPrinterPopUpView.frame.size.height-60);
        EditPrinterView.contentSize=CGSizeMake(EditPrinterPopUpView.frame.size.width-100,EditPrinterPopUpView.frame.size.height+500);
        
        CGFloat EditPrinterw=EditPrinterView.frame.size.width/3;
        
        EditprintCharLabel .frame=CGRectMake(EditPrinterw, 20, EditPrinterw, 30);
        
        EditprinterCharTF.frame = CGRectMake(EditPrinterw, 55, EditPrinterw, 30);
        
        EditfontLabel.frame = CGRectMake(EditPrinterw, 85, EditPrinterw, 30);
        
        EditfontButton.frame=CGRectMake(EditPrinterw, 115, 200, 30);
        
        EditalignLineSpaLabel .frame= CGRectMake(EditPrinterw, 145, EditPrinterw, 30);
        
        EditalignLineSpaButton.frame=CGRectMake(EditPrinterw, 175, 200, 30);
        
        EditlangLabel .frame= CGRectMake(EditPrinterw, 205, EditPrinterw, 30);
        
        EditlanguageButton.frame=CGRectMake(EditPrinterw, 235, 200, 30);
        
        
        EditsizeLabel .frame= CGRectMake(EditPrinterw, 265, EditPrinterw, 30);
        
        EditsizeButton.frame=CGRectMake(EditPrinterw, 295, EditPrinterw/2, 30);
        
        EditwidthButton.frame=CGRectMake(EditPrinterw+EditsizeButton.frame.size.width+5, 295, EditPrinterw/2, 30);
        
        EditstyleLabel .frame= CGRectMake(EditPrinterw, 325, EditPrinterw/2, 30);
        
        EditboldLabel .frame=CGRectMake(EditPrinterw+10, 355, EditPrinterw/2, 30);
        
        EditboldSwitch.frame=CGRectMake(EditPrinterw+10+EditboldLabel.frame.size.width, 355, 100, 30);
        
        EditunderLineLabel .frame=CGRectMake(EditPrinterw+10, 385, EditPrinterw, 30);
        
        EditunderlineSwitch.frame=CGRectMake(EditPrinterw+10+boldLabel.frame.size.width, 390, 100, 30);
        
        EditxPositionLabel .frame=CGRectMake(EditPrinterw, 415, EditPrinterw, 30);
        
        EditxPositionTF.frame =CGRectMake(EditPrinterw, 445, EditPrinterw, 30);
        
        EditfeedUnitLabel.frame = CGRectMake(EditPrinterw, 475, EditPrinterw, 30);
        
        EditfeedUnitTF .frame=CGRectMake(EditPrinterw, 505, EditPrinterw, 30);
        
        EditPrintertypelabel .frame= CGRectMake(EditPrinterw, 535, EditPrinterw, 30);
        
        EditPrinterTypeBtn.frame=CGRectMake(EditPrinterw, 565, 200, 30);
        
        
        EditPrinterNameLabel.frame = CGRectMake(EditPrinterw, 595, EditPrinterw, 30);
        
        
        EditprinterNameButton.frame=CGRectMake(EditPrinterw, 625, 200, 30);
        
        EditprinterIDLabel.frame = CGRectMake(EditPrinterw, 655, EditPrinterw, 30);
        
        EditprinteridTF .frame= CGRectMake(EditPrinterw, 685, EditPrinterw, 30);
        
        EditipAddressLabel.frame =CGRectMake(EditPrinterw, 715, EditPrinterw, 30);
        
        
        EditipAddressTF .frame=CGRectMake(EditPrinterw, 745, EditPrinterw, 30);
        
        EditfontTableView.frame = CGRectMake(EditPrinterw, 116, 200, 100) ;
        
        EditalignLineSpaTV.frame = CGRectMake(EditPrinterw, 178, 200, 100) ;
        
        EditlanguageTV.frame =CGRectMake(EditPrinterw, 238, 200, 100);
        
        EditsizeWidthTV.frame = CGRectMake(EditPrinterw, 298, EditPrinterw/2, 100);
        
        EditsizeHeightTV.frame = CGRectMake(EditPrinterw+sizeButton.frame.size.width+5, 298, EditPrinterw/2, 100);
        EditPrinterTypesTable.frame = CGRectMake(EditPrinterw, 568, 200, 100);
        EditprinterNameTV .frame= CGRectMake(EditPrinterw, 628, 200, 100);
        
        EditLignSpacelbl.frame = CGRectMake(EditPrinterw,775, EditPrinterw, 30);
        
        EditalignLineSpaTF.frame =CGRectMake(EditPrinterw, 805, EditPrinterw, 30);
        
        EditsaveButton.frame= CGRectMake(EditPrinterw,850, EditPrinterw, 40);
        editwifiLabel.frame = CGRectMake(EditPrinterw+EditPrinterw+5, 565, 50, 30);
        
        editwifi_Switch.frame=CGRectMake(EditPrinterw+EditPrinterw+55, 565, 100, 30);
        
        editbtLabel.frame =CGRectMake(EditPrinterw+EditPrinterw+125, 565, 100, 30);
        
//Server Url View
        ServerUrlBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        ServerView.frame=CGRectMake(10, 10, ServerUrlBackView.frame.size.width-20, ServerUrlBackView.frame.size.height-20);
        
        CGFloat ServerW=ServerView.frame.size.width/3;
        ServerUrllbl.frame=CGRectMake(ServerW-60,100 ,150, 50);
        ServerTextView.frame= CGRectMake(ServerW+ServerUrllbl.frame.size.width-100, 107, ServerW+100, 40);
        
        SaveServerUrlBtn.frame=CGRectMake(ServerW+50+ServerW/2,160, 100, 40);
        
        
        
        
//Card View
        
        
        CardBackView.frame=CGRectMake(10, maintoolBar.frame.size.height+10, (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CardView.frame=CGRectMake(10, 10, CardBackView.frame.size.width-20, CardBackView.frame.size.height-20);
        CardView.contentSize=CGSizeMake( CardBackView.frame.size.width-20, CardBackView.frame.size.height+100);
        
        
        CGFloat CardW=CardView.frame.size.width/2;
        CGFloat cardX=CardW/2;
        
        
        paymentLabel.frame=CGRectMake(cardX-100,30 ,300,40);
        
        paymentButton.frame=CGRectMake(cardX-100, 80, 250, 40);
        paymentTableView .frame=CGRectMake(cardX-100, 120, 250, 80) ;
        
        primaryurllbl.frame=CGRectMake(cardX-100,150 ,180,40);
        
        PrimaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 150, CardW,40);
        
        Securllbl.frame=CGRectMake(cardX-100,210 ,180,40);
        
        SecondaryField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 210, CardW,40);
        
        
        merchantNolbl.frame=CGRectMake(cardX-100,270 ,180,40);
        
        MerchantField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 270, CardW,40);
        
        
        terminalNolbl.frame=CGRectMake(cardX-100,330 ,180,40);
        
        TerminalField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 330, CardW,40);
        
        
        
        ProcessBtn.frame=CGRectMake(cardX-80,395 ,30,30);
        
        Processdebittextlbl.frame=CGRectMake(cardX-30,390,CardW+CardW/2, 40);
        
        
        RequireBtn.frame=CGRectMake(cardX-80,445 ,30,30);
        
        requiretextlbl.frame=CGRectMake(cardX-30,440,CardW+CardW/2, 40);
        
        saveCardDataBtn.frame= CGRectMake(CardW-40,520, 100, 40);
        timeoutlbl.frame=CGRectMake(cardX-100,390 ,180,40);
        timeoutTextField.frame=CGRectMake(cardX+primaryurllbl.frame.size.width-50, 390, CardW,40);
        
        //Company view
        
        HomeImageView.frame=CGRectMake(20,20,Homewdth-80,Homewdth-80);
        
        HomeImageBtn.frame=CGRectMake(40,Homewdth-40,Homewdth-80,40);
        
        //merchant view
        CGFloat merchantW=CompanyView.frame.size.width/2;
        
        merchantDataLabel .frame=CGRectMake(merchantW+60, 20, merchantW, 30);
        
        merchantNameLabel.frame=CGRectMake(merchantW+10, 80, 100, 30);
        
        merchantnameTf .frame=CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 80,  merchantW/2, 30);
        
        addressLabel.frame =CGRectMake(merchantW+10, 140,100, 30);
        
        addressTf.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 140, merchantW/2, 30);
        
        addressLabel2.frame=CGRectMake(merchantW+10, 200,100, 30);
        
        addressTf2.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 200, merchantW/2, 30);
        
        phNoLabel.frame =CGRectMake(merchantW+10, 260,100, 30);
        
        phNoTf.frame =CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 260, merchantW/2, 30);
        
        zipcodeLabel.frame =CGRectMake(merchantW+10, 320, 100, 30);
        
        zipcodeTf.frame=CGRectMake(merchantW+10+merchantNameLabel.frame.size.width+30, 320,  merchantW/2, 30);
        savemerchantDataBtn.frame= CGRectMake(merchantW+100,380, 100, 40);
    }
}
-(void)radiobuttonSelected1:(id)sender{
    
    switch ([sender tag]) {
        case 0:
            if([paymentenableradioBtn isSelected]==YES)
            {
                [paymentenableradioBtn setSelected:NO];
                [paymentdisableradioBtn setSelected:YES];
                
                
            }
            else{
                [paymentenableradioBtn setSelected:YES];
                [paymentdisableradioBtn setSelected:NO];
                
               // [[OriginalDB getSharedInstance]setPaymentvalue:@"YES"];
               
                
            }
            
            break;
        case 1:
            if([paymentdisableradioBtn isSelected]==YES)
            {
                [paymentdisableradioBtn setSelected:NO];
                [paymentenableradioBtn setSelected:YES];
                
            }
            else{
                [paymentdisableradioBtn setSelected:YES];
                [paymentenableradioBtn setSelected:NO];
                //[[OriginalDB getSharedInstance]setPaymentvalue:@"NO"];
            }
            break;
        default:
            break;
    }
}


-(void)radiobuttonSelected2:(id)sender{
    
    switch ([sender tag]) {
        case 0:
            if([payEnableBtn isSelected]==YES)
            {
                [payEnableBtn setSelected:NO];
                [payDisableBtn setSelected:YES];
                
                
            }
            else{
                [payEnableBtn setSelected:YES];
                [payDisableBtn setSelected:NO];
                
               // [[OriginalDB getSharedInstance]setPaymentvalue:@"YES"];
                //// //NSLog(@"%@",[[OriginalDB getSharedInstance]paymentvalue]);
                
            }
            
            break;
        case 1:
            if([payDisableBtn isSelected]==YES)
            {
                [payDisableBtn setSelected:NO];
                [payEnableBtn setSelected:YES];
                
            }
            else{
                [payDisableBtn setSelected:YES];
                [payEnableBtn setSelected:NO];
               //[[OriginalDB getSharedInstance]setPaymentvalue:@"NO"];
                //// //NSLog(@"%@",[[OriginalDB getSharedInstance]paymentvalue]);
            }
            break;
        default:
            break;
    }
}
-(void)radiobuttonSelected3:(id)sender{
    
    switch ([sender tag]) {
        case 0:
            if([setYesBtn isSelected]==YES)
            {
                [setYesBtn setSelected:NO];
                [setNoBtn setSelected:YES];
                
                
            }
            else{
                [setYesBtn setSelected:YES];
                [setNoBtn setSelected:NO];
                
                
            }
            break;
        case 1:
            if([setNoBtn isSelected]==YES)
            {
                [setNoBtn setSelected:NO];
                [setYesBtn setSelected:YES];
                
            }
            else{
                [setNoBtn setSelected:YES];
                [setYesBtn setSelected:NO];
                
                
                }
            break;
        default:
            break;
    }
}


-(void)menuclicked
{
    if (menuslected == false)
    {
        
       // // //NSLog(@"called");
        //// //NSLog(@"%d",menuslected);
        menuslected=YES;
        logoBtn.hidden=YES;
        
       // [UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(0,0);
        //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
        //sidemenu.hidden=NO;
        //[UIView commitAnimations];
        [backgroundcolorview addSubview:sidemenu];
        
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:0.9f];
        menubutton.transform = CGAffineTransformMakeTranslation(180,0);
        
        menubutton.transform = CGAffineTransformRotate( menubutton.transform, - M_PI);
       // [UIView commitAnimations];
        //[UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        
        
    }else
    {
        
        menuslected=NO;
        logoBtn.hidden=NO;
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
        
       // [UIView commitAnimations];
     
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        menubutton.transform = CGAffineTransformMakeTranslation(0,0);
        
        
        //[UIView commitAnimations];
       // [UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        
    }
    
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
    logoBtn.hidden=NO;
    //[UIView beginAnimations:nil context:NULL];
    //[UIView setAnimationDuration:0.8f];
    mainview.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    //[UIView commitAnimations];
    //[UIView beginAnimations:nil context:NULL];
   // [UIView setAnimationDuration:0.8f];
    sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
    //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
    
   // [UIView commitAnimations];
    //[UIView commitAnimations];
    //[UIView beginAnimations:nil context:NULL];
   // [UIView setAnimationDuration:0.0f];
    menubutton.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    //[UIView commitAnimations];
    //[UIView beginAnimations:nil context:NULL];
    //[UIView setAnimationDuration:0.0f];
    menuslected=NO;
    
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [EditPrinterView removeFromSuperview];
    NSArray *EditPrinterViewArray = EditPrinterView.subviews;
    for (int i = 0; i<[EditPrinterViewArray count]; i++) {
        UIView *vi =[EditPrinterViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *EditPrinterPopUpViewArray = EditPrinterPopUpView.subviews;
    for (int i = 0; i<[EditPrinterPopUpViewArray count]; i++) {
        UIView *vi =[EditPrinterPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditPrinterView removeFromSuperview],[EditPrinterPopUpView removeFromSuperview];
    [editPaymentPopup removeFromSuperview];
    [edittaxpopup removeFromSuperview];
}

-(void)helpiconclicked
{
    
    
}
-(void)logoutButtonClicked
{
     [serverSyncClassObject LogoutMethod];
    NSString *updateSQL =@"UPDATE miscellaneous SET userType=?,sessionId=?,userID=?";
    NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"",@"",@"", nil];
    [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    [self releaseViews];
    [generalDataObject  releasevariable];
}

-(void)categotybuttonclicked:(UIButton *)sender
{
    NSInteger selectedrow=sender.tag;
    NSArray *viewS = [self.navigationController viewControllers];
    ////NSLog(@"nav views %@",viewS);
    if(selectedrow == 0){
         Home *homeview=[[Home alloc]initWithNibName:@"Home" bundle:Nil];
        NSString *returnvalue;
        NSInteger selectedview;
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Home class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        ////NSLog(@"%d",selectedview);
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else{
          
            [self.navigationController pushViewController:homeview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 1){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Profile *profileview=[[Profile alloc]initWithNibName:@"Profile" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Profile class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:profileview animated:NO];
                [self releaseViews];
            }
            
        }else{
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
            authalert=nil;
        }
    }else if(selectedrow == 8){
        NSString *returnvalue;
        NSInteger selectedview;
        Stores *storesview=[[Stores alloc]initWithNibName:@"Stores" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Stores class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:storesview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 2){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  inventory_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:inventoryview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }
        else
        {
            
            NSString *returnvalue;
            NSInteger selectedview;
            Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:inventoryview animated:NO];
                [self releaseViews];
            }
        }
    }else if(selectedrow == 3){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  customer_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:customersview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:customersview animated:NO];
                [self releaseViews];
            }
        }
        
    }else if(selectedrow == 4){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Employees *employeesview=[[Employees alloc]initWithNibName:@"Employees" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Employees class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:employeesview animated:NO];
                [self releaseViews];
            }
        }
        else
        {
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
        }
        
    }else if(selectedrow == 6){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:reportsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:reportsview animated:NO];
                [self releaseViews];
            }
            
        }
        
    }else if(selectedrow == 7){
        NSString *returnvalue;
        NSInteger selectedview;
        Contacts *contactsview=[[Contacts alloc]initWithNibName:@"Contacts" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Contacts class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:contactsview animated:NO];
            [self releaseViews];
        }

    }
  
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    
   [textField resignFirstResponder];
    [dataField resignFirstResponder];
    
    return YES;
}


- (NSUInteger)supportedInterfaceOrientations // iOS 6 autorotation fix
{
    return UIInterfaceOrientationMaskAll;
}


-(void)releaseViews{
    

    NSArray *mainArray = self.view.subviews;
    for (int i = 0; i<[mainArray count]; i++) {
        UIView *vi =[mainArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *sideArray = sidemenu.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = navBar.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [sidemenu removeFromSuperview],[backgroundcolorview removeFromSuperview];

    [printcharArray removeAllObjects], [FontsArray removeAllObjects], [AlignsArray removeAllObjects], [languagesArray removeAllObjects],[WidthsArray removeAllObjects],[HeightsArray removeAllObjects],    [boldsArray removeAllObjects], [UnderlinesArray removeAllObjects], [XpossArray removeAllObjects], [unitsArray removeAllObjects],[spacingsArray removeAllObjects],[printernamesArray removeAllObjects],    [IpAddsArray removeAllObjects], [PrinterIdsArray removeAllObjects], [PrintertypesArray removeAllObjects],[DbPrinterTypesArray removeAllObjects],[deptSArray removeAllObjects],[ChecksArray removeAllObjects],[ItemChecksArray removeAllObjects];
    [searchPrinterArray removeAllObjects],[dataDict removeAllObjects],[EdittaxArray removeAllObjects],[DepartmentsArray removeAllObjects],[ItemsArray removeAllObjects];
    
    sidemenu= nil,mainview= nil,backgroundcolorview= nil;
    categorybutton= nil;
    downtoolBar= nil,maintoolBar= nil;
    logobackview= nil,logoimageview= nil;
    helpiconButton= nil,logouticonButton= nil,menubutton= nil;
    Applicationbarbtn= nil,Printerbarbtn= nil,taxbarbtn= nil,paymentbarbtn= nil,DBbarbtn= nil,dataresetbarbtn= nil,CompanyBtn= nil,CardBtn= nil;
    navBar= nil;
    scrollView= nil;
    //Db backup view
    NSArray *addDBBackupViewArray = addDBBackupView.subviews;
    for (int i = 0; i<[addDBBackupViewArray count]; i++) {
        UIView *vi =[addDBBackupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *DbbackUpviewArray = DbbackUpview.subviews;
    for (int i = 0; i<[DbbackUpviewArray count]; i++) {
        UIView *vi =[DbbackUpviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addDBBackupView removeFromSuperview],[DbbackUpview removeFromSuperview];
    //TS view
    NSArray *addApplicationDataViewArray = addApplicationDataView.subviews;
    for (int i = 0; i<[addApplicationDataViewArray count]; i++) {
        UIView *vi =[addApplicationDataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ApplicationViewArray = ApplicationView.subviews;
    for (int i = 0; i<[ApplicationViewArray count]; i++) {
        UIView *vi =[ApplicationViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [addApplicationDataView removeFromSuperview],[ApplicationView removeFromSuperview];
    //tax view
    NSArray *AddTaxViewArray = AddTaxView.subviews;
    for (int i = 0; i<[AddTaxViewArray count]; i++) {
        UIView *vi =[AddTaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *TaxViewArray = TaxView.subviews;
    for (int i = 0; i<[TaxViewArray count]; i++) {
        UIView *vi =[TaxViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddTaxView removeFromSuperview],[TaxView removeFromSuperview];
    ApplicationView= nil,TaxView= nil,AddTaxView= nil;
    
    nameTextfield= nil,RateTextfield= nil,changetaxField= nil,changerateField= nil,paymentnameField= nil;
    namelabel= nil,RateLabel= nil,paymentnamelbl= nil,paymenttaxlbl= nil,disablepaymentlbl= nil,enablepaymentlbl= nil;
    taxnamelbl= nil,ratetaxlbl= nil;
    SaveTaxButton= nil,CancelTaxButton= nil,changesavetax= nil,changecanceltax= nil,savepaymentBtn= nil,cancelpaymentBtn= nil,paymentenableradioBtn= nil,paymentdisableradioBtn= nil,addpaymentBtn= nil,editpaymentBtn= nil;
    edittaxTable= nil,PaymentTable= nil;
    deletetaxAlert= nil,deletePaymentAlert= nil;
    editBtn= nil,viewbtn= nil;
    namelbl= nil, taxlbl= nil;
    addtaxBtn= nil,editTaxButton= nil;
    edittaxpopup= nil,editPaymentPopup= nil;
    name= nil,taxrate= nil;
    deletepaymentBtn= nil,editPaymentBtn= nil;
    payNameStr= nil,payValueStr= nil;
    
    EdittaxBackView= nil;
    
    
    //paypopup view
    NSArray *AddpaymentViewArray = AddpaymentView.subviews;
    for (int i = 0; i<[AddpaymentViewArray count]; i++) {
        UIView *vi =[AddpaymentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *paymentviewArray = paymentview.subviews;
    for (int i = 0; i<[paymentviewArray count]; i++) {
        UIView *vi =[paymentviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    
    [AddpaymentView removeFromSuperview],[paymentview removeFromSuperview];
    paymentview= nil,AddpaymentView= nil;
    paynameLbl= nil,payValuelbl= nil,enablePaylbl= nil,disablePaylbl= nil;
    payNametext= nil;
    payEnableBtn= nil,payDisableBtn= nil,CancelpayBtn= nil,SaveChangePayBtn= nil;
    
    //reset db view
    NSArray *dataresetViewArray = dataresetView.subviews;
    for (int i = 0; i<[dataresetViewArray count]; i++) {
        UIView *vi =[dataresetViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ResetviewArray = Resetview.subviews;
    for (int i = 0; i<[ResetviewArray count]; i++) {
        UIView *vi =[ResetviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
     [dataresetView removeFromSuperview],[Resetview removeFromSuperview];
    dataresetView= nil,Resetview= nil;
    Titlelbl= nil,resetAllLbl= nil,ProductsLbl= nil,selllLbl= nil,customerlbl= nil,textLabel= nil,yeslbl= nil,Nolbl= nil;
    resetAllBtn= nil,ProductsBtn= nil,SellBtn= nil,CustomerBtn= nil,resetButton= nil,setYesBtn= nil,setNoBtn= nil;
    resetdataAlert= nil;
    //printer view
    
    NSArray *addprinterdataViewArray = addprinterdataView.subviews;
    for (int i = 0; i<[addprinterdataViewArray count]; i++) {
        UIView *vi =[addprinterdataViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *printerviewArray = printerview.subviews;
    for (int i = 0; i<[printerviewArray count]; i++) {
        UIView *vi =[printerviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addprinterdataView removeFromSuperview],[printerview removeFromSuperview];

    printerview= nil;
    addprinterdataView= nil;
    columnnamestr= nil,feedstr= nil,spacingstr= nil,columnsizeStr= nil;
    textlbl= nil,fieldslbl= nil;
    dataField= nil,printernameField= nil,printeridField= nil;
    updateButton= nil,getprinterstatusBtn= nil;
    aligndataTable= nil,fontsTable= nil,printermethodsTable= nil;
    
    aligndataArray= nil,fontsizesArray= nil,printmethodsArray= nil;
    alignButton= nil,fontsizeBtn= nil,printermethodBtn= nil;
    //DB Bacup view
    DbbackUpview= nil,addDBBackupView= nil;
    ServerSynBtn= nil,UploadXlsBtn= nil,ExportDatabaseBtn= nil,ImportDatabaseBtn= nil;
    
    
    
    SynAlertview= nil;
    
    //Applicatiopn View= nil;
    addApplicationDataView= nil;
    AppTextLbl= nil;
    DeptBtn= nil,ItemsBtn= nil;
    DepartmentsTable= nil,ItemsTable= nil;
    SaveTsBtn= nil,CancelTsBtn= nil,DeptCheckBox= nil,ItemCheckBox= nil;
    [DepartmentsArray removeAllObjects],[ItemsArray removeAllObjects];
    DepartmentsArray= nil,ItemsArray= nil;
    
    saveDeptsBtn= nil,SaveItemsBtn= nil;
    
    //Company View
    NSArray *CompanyViewArray = CompanyView.subviews;
    for (int i = 0; i<[CompanyViewArray count]; i++) {
        UIView *vi =[CompanyViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CompanyBackViewArray = CompanyBackView.subviews;
    for (int i = 0; i<[CompanyBackViewArray count]; i++) {
        UIView *vi =[CompanyBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CompanyView removeFromSuperview],[CompanyBackView removeFromSuperview];
    CompanyBackView= nil;
    CompanyView= nil;
    HomeImageBtn= nil;
    HomeImageView= nil;
    imgpicker= nil;
    selectedimage= nil;
     [ChecksArray removeAllObjects],[ItemChecksArray removeAllObjects],[deptSArray removeAllObjects];
    deptSArray= nil;
    
    ChecksArray= nil,ItemChecksArray= nil;
    
    //Divya Printer View
    
    //Divya
    addPrintButton= nil,editPrinterButton= nil;
    printCharLabel= nil,  fontLabel= nil,  alignLineSpaLabel= nil,  langLabel= nil, sizeLabel= nil,  styleLabel= nil, underLineLabel= nil, xPositionLabel= nil,  feedUnitLabel= nil,  PrinterNameLabel= nil,  printerIDLabel= nil,  ipAddressLabel= nil,  boldLabel= nil,LignSpacelbl= nil,PrinterTypeLabel= nil;
    
    printerCharTF= nil;
    
    alignLineSpaTF= nil,  langTF= nil, xPositionTF= nil,  feedUnitTF= nil,  printeridTF= nil,  ipAddressTF= nil;
   
    fontArray= nil,  alignLineSpacArray= nil,  langArray= nil,  sizeWidthArray= nil,  sizeheightArray= nil,  printerNameArray= nil;
    
    fontTableView= nil,  alignLineSpaTV= nil,  languageTV= nil, sizeWidthTV= nil,  sizeHeightTV= nil, printerNameTV= nil;
    
    fontButton= nil,  alignLineSpaButton= nil, languageButton= nil, sizeButton= nil, widthButton= nil, printerNameButton= nil,  saveButton= nil,PrinterTypeBtn= nil;
    
    boldSwitch= nil, underlineSwitch= nil;
    editPrinterTable= nil,PrinterTypesTable= nil;
    
    Bold= nil,Underline= nil;
      [printcharArray removeAllObjects],[FontsArray removeAllObjects],[languagesArray removeAllObjects],[WidthsArray removeAllObjects],[HeightsArray removeAllObjects],[boldsArray removeAllObjects],[UnderlinesArray removeAllObjects],[XpossArray removeAllObjects],[unitsArray removeAllObjects],[spacingsArray removeAllObjects],[printernamesArray removeAllObjects],[IpAddsArray removeAllObjects],[PrinterIdsArray removeAllObjects],[PrintertypesArray removeAllObjects];
    printcharArray= nil,FontsArray= nil,languagesArray= nil,WidthsArray= nil,HeightsArray= nil,boldsArray= nil,UnderlinesArray= nil,XpossArray= nil,unitsArray= nil,spacingsArray= nil,printernamesArray= nil,IpAddsArray= nil,PrinterIdsArray= nil,PrintertypesArray= nil;
    
    PrinterAlert= nil;
    Printer1Label= nil;
    
    //Edit printer View
    NSArray *EditPrinterViewArray = EditPrinterView.subviews;
    for (int i = 0; i<[EditPrinterViewArray count]; i++) {
        UIView *vi =[EditPrinterViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *EditPrinterPopUpViewArray = EditPrinterPopUpView.subviews;
    for (int i = 0; i<[EditPrinterPopUpViewArray count]; i++) {
        UIView *vi =[EditPrinterPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditPrinterView removeFromSuperview],[EditPrinterPopUpView removeFromSuperview];
    EditPrinterPopUpView= nil;
    EditPrinterView= nil;
    
    EditprintCharLabel= nil, EditfontLabel= nil, EditalignLineSpaLabel= nil, EditlangLabel= nil, EditsizeLabel= nil, EditstyleLabel= nil,EditunderLineLabel= nil, EditxPositionLabel= nil, EditfeedUnitLabel= nil,  EditPrinterNameLabel= nil,  EditprinterIDLabel= nil,  EditipAddressLabel= nil,  EditboldLabel= nil,EditLignSpacelbl= nil,EditPrintertypelabel= nil;
    
    EditprinterCharTF= nil;
    
    EditalignLineSpaTF= nil,  EditlangTF= nil, EditxPositionTF= nil,  EditfeedUnitTF= nil,  EditprinteridTF= nil,  EditipAddressTF= nil;
    EditfontTableView= nil,  EditalignLineSpaTV= nil,  EditlanguageTV= nil, EditsizeWidthTV= nil,  EditsizeHeightTV= nil, EditprinterNameTV= nil,EditPrinterTypesTable= nil;
    
    EditfontButton= nil,  EditalignLineSpaButton= nil, EditlanguageButton= nil, EditsizeButton= nil, EditwidthButton= nil, EditprinterNameButton= nil, EditsaveButton= nil,EditPrinterTypeBtn= nil;
    
    EditboldSwitch= nil, EditunderlineSwitch= nil;
    
    PrinterName= nil;
    [DbPrinterTypesArray removeAllObjects];
    DbPrinterTypesArray= nil;
    
    //Server url View
    NSArray *ServerViewArray = ServerView.subviews;
    for (int i = 0; i<[ServerViewArray count]; i++) {
        UIView *vi =[ServerViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ServerUrlBackViewArray = ServerUrlBackView.subviews;
    for (int i = 0; i<[ServerUrlBackViewArray count]; i++) {
        UIView *vi =[ServerUrlBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ServerView removeFromSuperview],[ServerUrlBackView removeFromSuperview];
    ServerUrlBackView= nil,ServerView= nil;
    
    ServerUrllbl= nil;
    ServerTextView= nil;
    SaveServerUrlBtn= nil;
    
    ServerUrlAlert= nil;
    
    
    //Card View
    NSArray *CardViewArray = CardView.subviews;
    for (int i = 0; i<[CardViewArray count]; i++) {
        UIView *vi =[CardViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CardBackViewArray = CardBackView.subviews;
    for (int i = 0; i<[CardBackViewArray count]; i++) {
        UIView *vi =[CardBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [CardView removeFromSuperview],[CardBackView removeFromSuperview];
    CardBackView= nil;
    CardView= nil;
    primaryurllbl= nil,Securllbl= nil,merchantNolbl= nil,terminalNolbl= nil,Processdebittextlbl= nil,requiretextlbl= nil;
    PrimaryField= nil,SecondaryField= nil,MerchantField= nil,TerminalField= nil;
    saveCardDataBtn= nil,ProcessBtn= nil,RequireBtn= nil;
    timeoutlbl=nil,timeoutTextField=nil;
    
    
    connection1= nil;
    ServerurlStr= nil;
    
    sationLbl= nil,Timelbl= nil,EmpIdlbl= nil;
    logoBtn= nil;
    
    
    CompanyTextF= nil;
    SubmitCmpyBtn= nil;
    
    
    RegisterConnection= nil;
    RegisterResponseData= nil;
    
    SavecompanyAlert= nil;
    
    //changes in card data
    
    paymentLabel= nil;
    
    paymentButton= nil;
    
    paymentTableView= nil;
    
    paymentArray= nil;
    paymentStr= nil;
    
    InvConnection= nil,DeptConnection= nil;
    InvResponseData= nil,DeptResponseData= nil;
    [EdittaxArray removeAllObjects];
    EdittaxArray= nil;
     printerCell= nil;
     taxesCell= nil;
     paymentCell= nil;
    
    wifiLabel= nil,btLabel= nil;
    wifi_Switch= nil;
    
    editwifiLabel= nil,editbtLabel= nil;
    editwifi_Switch= nil;
    SearchPrinterStr= nil;
    [searchPrinterArray removeAllObjects];
    searchPrinterArray= nil;
    dataDict= nil;
    myurlstring= nil;
    [self.view removeFromSuperview];
    self.view=nil;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    NSArray *viewS = [self.navigationController viewControllers];
    [self.navigationController popToViewController:[viewS objectAtIndex:1] animated:YES];
    [self releaseViews];
    // Dispose of any resources that can be recreated.
}

@end
